What is wrong with my code? please help

programming
Tags: #<Tag:0x00007f2428118278>

#1

prev=1;

for(i=0;i<n1;i++){
    
    cur=1;
    if(i==0){
        cur=1;
    }
    else{
        if(A[i]>A[i-1]){
            cur=prev+1;
        }
    }
    prev=cur;
   B[i]=cur;
}
prev=A[n1-1];
sum=B[n1-1];
for(i=n1-2;i>=0;i--){

    if(A[i]>A[i+1]){
        cur=prev+1;
        if(B[i]<cur){
            
            B[i]=cur;
       }
    }
    else{
        cur=B[i];
    }
    prev=cur;
    sum+=B[i];
}

return sum;