Sorting

Hello everybody ! Now I have problem hard for me. Because I’m don’t understand topic : Problem - B - Codeforces . I known - have 2 * n people, have n - 1 tandem kayaks and 2 single kayaks. i"th person weight is wi. I known he instability of a single kayak is always 0, and the instability of a tandem kayak is the absolute difference between weights of the people that are in this kayak. Let’s help me !!!