#abc129b. [abc129_b]Balance

[abc129_b]Balance

Problem Statement

We have NN weights indexed 11 to NN. The mass of the weight indexed ii is WiW_i.

We will divide these weights into two groups: the weights with indices not greater than TT, and those with indices greater than TT, for some integer 1leqT<N1 \\leq T < N. Let S1S_1 be the sum of the masses of the weights in the former group, and S2S_2 be the sum of the masses of the weights in the latter group.

Consider all possible such divisions and find the minimum possible absolute difference of S1S_1 and S2S_2.

Constraints

  • 2leqNleq1002 \\leq N \\leq 100
  • 1leqWileq1001 \\leq W_i \\leq 100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN W1W_1 W2W_2 ...... WN1W_{N-1} WNW_N

Output

Print the minimum possible absolute difference of S1S_1 and S2S_2.


Sample Input 1

3
1 2 3

Sample Output 1

0

If T=2T = 2, S1=1+2=3S_1 = 1 + 2 = 3 and S2=3S_2 = 3, with the absolute difference of 00.


Sample Input 2

4
1 3 1 1

Sample Output 2

2

If T=2T = 2, S1=1+3=4S_1 = 1 + 3 = 4 and S2=1+1=2S_2 = 1 + 1 = 2, with the absolute difference of 22. We cannot have a smaller absolute difference.


Sample Input 3

8
27 23 76 2 3 5 62 52

Sample Output 3

2