maximum weight difference problem showing wrong answer

can anyone please tell why it is showing wrong answer … CodeChef: Practical coding for everyone

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)))