N = int(eval(input()))

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

print((min(abs(sum(W[:i])-sum(W[i:])) for i in range(N))))
N = int(eval(input()))

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

ans = float('inf')

for i in range(N-1):

  ans=min(ans,abs(sum(W[:i+1])-sum(W[i+1:])))

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

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

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