A B-tree would be the most convenient way of doing this to get the first 2 (at most) combinations of groupings.
It occurs to me that an ordered binary tree might work as well. Consider the layout:
[This is theory on my part]
The way to generate a close pair of sums would be to alternate addition, like so:
1 -> Set 1
2 -> Set 2
3 -> Set 2
4 -> Set 1
5 -> Set 1
6 -> Set 2
8 -> Set 2
Because this is an odd number, this is not *the* closest (Set 2 is ahead by 9) -- a conditional statement could be added to the end of the addition to ensure that the closest pair is noted as such (adding 8 to Set 1 would be appropriate in this case, with a difference of only 7 between the sets). Because you are constrained to | n
1 - n
2 <= 1, I am fairly certain this is the best way to expect results.
To make incremental changes to see larger results than this, you can alternate the order in which the first elements are added. For example, 1->Set 2, 2->Set 1, 3->Set 1, etc, then 1->Set1, 2->Set 1, 3->Set 2, 4->Set 2, 5->Set 1.... The difference between sums gets larger, of course, but you should have already determined the difference in sums.