n = int(eval(input()))

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



m=[]

for i in range(1,n):

    m.append(abs(sum(w[:i]) - sum(w[i:])))

print((min(m)))
n=int(eval(input()))

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



ans=float("inf")

for i in range(n):

      ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)
n = int(eval(input()))
w = list(map(int, input().split()))
m = []
for i in range(1, n):
    m.append(abs(sum(w[:i]) - sum(w[i:])))
print((min(m)))

n = int(eval(input()))
w = list(map(int, input().split()))
ans = float("inf")
for i in range(n):
    ans = min(ans, abs(sum(w[:i]) - sum(w[i:])))
print(ans)

-m = [] -for i in range(1, n): -    m.append(abs(sum(w[:i]) - sum(w[i:]))) -print((min(m))) +ans = float("inf") +for i in range(n): +    ans = min(ans, abs(sum(w[:i]) - sum(w[i:]))) +print(ans)