Problem in scoring

I submitted the correct code but for the 3rd case it showed wrong answer but when i downloaded the third test case and ran it on my laptop, my exactly same code which i had submitted gave the correct answer. I think there is a problem with the spacing. Else please correct me.

plz send your code here, so that we could check it

#include using namespace std; int main() { int n, i, sum=0; cin >> n; int arr[n+1]; for(i=0; i<n; i++) {cin >> arr[i];} arr[n] = 0; i=1; while(i<n-1) { if(arr[i-1] < arr[i] || arr[i+1] < arr[i]) {i++;} else { int j=i+1, k=i-1; int maxr=arr[j], maxl=arr[k]; for(j=j; j<n; j++) { maxr = arr[j]; if(arr[j+1] >= maxr) {maxr = arr[j+1];} else {break;} } for(k=k; k>=0; k–) { if(arr[k-1] >= maxl) {maxl = arr[k-1];} else {break;} } int min_ht = min(maxl, maxr); for(int p=i; p<j; p++) {sum = sum + (min_ht - arr[p]);} for(int p=i-1; p>k; p–) {sum = sum + (min_ht - arr[p]);} i=j+1; } } cout << sum; return 0; }

The test case for which this is showing wrong answer is 3 2 0 2.

The expected output of which is 2 which i am getting. On trying the similar pattern of values is as what is expected.

Plz send your code by saving on ide, i m not able to understand your code like this