N = int(eval(input()))

W = [int(i) for i in input().split()]



A = sum(W)

ans = float('inf')

for i in range(N):

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

    ans = min(ans, tmp)

    

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

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



diff = float('inf')

for i in range(1, n):

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

    if x < diff:

        diff = x

        

print(diff)
N = int(eval(input()))
W = [int(i) for i in input().split()]
A = sum(W)
ans = float("inf")
for i in range(N):
    tmp = abs(sum(W[:i]) - (A - sum(W[:i])))
    ans = min(ans, tmp)
print(ans)

n = int(eval(input()))
W = list(map(int, input().split()))
diff = float("inf")
for i in range(1, n):
    x = abs(sum(W[:i]) - sum(W[i:]))
    if x < diff:
        diff = x
print(diff)

-N = int(eval(input())) -W = [int(i) for i in input().split()] -A = sum(W) -ans = float("inf") -for i in range(N): -    tmp = abs(sum(W[:i]) - (A - sum(W[:i]))) -    ans = min(ans, tmp) -print(ans) +n = int(eval(input())) +W = list(map(int, input().split())) +diff = float("inf") +for i in range(1, n): +    x = abs(sum(W[:i]) - sum(W[i:])) +    if x < diff: +        diff = x +print(diff)