WA in CHEFBM

Please someone tell me for which testcases my code is failing;
I feel that the total difference in row only depends upon incrementation in last element and first element.
If I increment only middle values satisfying the condition then there won’t be any change in final answer as
the incremented value goes nearer next element and the same distance away from previous element so there wont be any effect on total value of whole row;
Please tell me whats wrong in my code?
codelink:https://www.codechef.com/viewsolution/7886842