maximum weight difference problem showing wrong answer

can anyone please tell why it is showing wrong answer … https://www.codechef.com/viewsolution/9578824

The logic behind this code is


1 . Sort the array in ascending order


2 . Calculate the sum of all digits as sum


2 . Calculate the sum of k digits from start as sum1


3 . Calculate the sum of k digits from end as sum2


4 . Answer=MaxOf((sum1-(sum-sum1)),(sum2-(sum-sum2)))