Quake Live is a first person shooter that supports several match types. The most popular one is the 4 on 4 team deathmatch. Eight players enter, they are split into two teams of four, and the teams fight to the death. The team whose players all die first loses.
The server keeps a match history for every player and estimates each player's skill level from it, as an integer between 1 and 1000. To keep a match as fair as possible, the server looks at the skill levels of the players who connect and splits them into two teams so that the difference between the sum of skills on team A and the sum of skills on team B is as small as possible.
You want to check that the server really does this. Given the skill levels of the players who enter, find the smallest possible difference between the two team totals. The two teams always have the same number of players.