Doubt in Codeforces problem: 1244E - Minimizing Difference

Can anyone please help me find out why my code is giving wrong answer for few test cases?
There is scope of optimization (binary search) in my solution but my problem is I am getting wrong answer for few cases.
My approach is same as what is mentioned in the tutorial too.
Link to problem is : Problem Link
My solution is : My solution
Just a few comments to understand my code:
First I sorted the array.
Then I have made two arrays, one (left array) holds the moves required for making (incrementing) all elements left to it to current value and right array hold moves required for making (decrementing) all values right of it to current value.
Then I iterate over left array (la) and find the closest possible right value from right array (ra) and then if still moves are left I choose left or right based on number of elements left and right to it and choosing the one with fewer elements and incrementing it to as far as possible.

Thanks in advance