N = int(eval(input()))

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

sum_w = sum(w)

ans = sum_w

T = 0

for i in range(N):

  if abs(sum(w[:i+1])-sum(w[i+1:]))<ans:

    ans = abs(sum(w[:i+1])-sum(w[i+1:]))

print(ans)
N = int(eval(input()))

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

ans = 10**9

for i in range(N):

  tmp = abs(sum(W[:i])-sum(W[i:]))

  if ans > tmp:

    ans = tmp

print(ans)
N = int(eval(input()))
w = list(map(int, input().split()))
sum_w = sum(w)
ans = sum_w
T = 0
for i in range(N):
    if abs(sum(w[: i + 1]) - sum(w[i + 1 :])) < ans:
        ans = abs(sum(w[: i + 1]) - sum(w[i + 1 :]))
print(ans)

N = int(eval(input()))
W = list(map(int, input().split()))
ans = 10**9
for i in range(N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    if ans > tmp:
        ans = tmp
print(ans)

-w = list(map(int, input().split())) -sum_w = sum(w) -ans = sum_w -T = 0 +W = list(map(int, input().split())) +ans = 10**9 -    if abs(sum(w[: i + 1]) - sum(w[i + 1 :])) < ans: -        ans = abs(sum(w[: i + 1]) - sum(w[i + 1 :])) +    tmp = abs(sum(W[:i]) - sum(W[i:])) +    if ans > tmp: +        ans = tmp