9428 - Subset Sum   

Description

Given N numbers. You need to separate them A and B such that is minimum.
Note that a set can be empty.

Input

Each case starts with a positive integer N, then the next line contains exactly N integers n1~nN.

A test case of N = 0 indicates the end of input, and should not be processed.

For case 1, 1<=N<=3, 0<=ni<=100
For case 2, 1<=N<=5, 0<=ni<=10000
For case 3, 1<=N<=10, 0<=ni<=100000
For case 4, 1<=N<=20, -1000000<=ni<=1000000

Hint: Try to enumerate all possible combinitions.

Output

Output one line per case that contains an integer denoting the minimum value of .

Sample Input  Download

Sample Output  Download

Tags




Discuss