Problem link — here
I found the editorial for this problem a little over the head. It made the question a little too complicated. I did it in a more easy way just by having two buckets S1 and S2. Start the series in descending order, to prevent some side cases and optimise the solution. Here is the logic: For each element i (1 <= i <= N), if the sum(S1)<=sum(S2), add the element in S1 or else add it in S2. At the end, all I had to do was calculate absolute difference of sum(S1)-sum(S2).
Cheers..!
solution link — here