N=int(eval(input()))

W=list(map(int,input().split(' ')))

T=0

S1=0

S2=0

list=[]

for j in range(N-1):

    for i in range(N):

        if i<=T :

            S1=S1+W[i]

        else :

            S2=S2+W[i]

    T+=1

    list.append(abs(S1-S2))

    S1=0

    S2=0

print((min(list)))

N = int(eval(input()))

W = list(map(int,input().split()))



temp = 0

list=[]

for i in range(N-1):

    list.append(abs(sum(W[:i+1]) - sum(W[i+1:])))



print((min(list)))

N = int(eval(input()))
W = list(map(int, input().split(" ")))
T = 0
S1 = 0
S2 = 0
list = []
for j in range(N - 1):
    for i in range(N):
        if i <= T:
            S1 = S1 + W[i]
        else:
            S2 = S2 + W[i]
    T += 1
    list.append(abs(S1 - S2))
    S1 = 0
    S2 = 0
print((min(list)))

N = int(eval(input()))
W = list(map(int, input().split()))
temp = 0
list = []
for i in range(N - 1):
    list.append(abs(sum(W[: i + 1]) - sum(W[i + 1 :])))
print((min(list)))

-W = list(map(int, input().split(" "))) -T = 0 -S1 = 0 -S2 = 0 +W = list(map(int, input().split())) +temp = 0 -for j in range(N - 1): -    for i in range(N): -        if i <= T: -            S1 = S1 + W[i] -        else: -            S2 = S2 + W[i] -    T += 1 -    list.append(abs(S1 - S2)) -    S1 = 0 -    S2 = 0 +for i in range(N - 1): +    list.append(abs(sum(W[: i + 1]) - sum(W[i + 1 :])))