N = int(eval(input()))

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

ans = sum(W)

for i in range(1,N):

    A = sum(W[0:i])

    B = sum(W[i:])

    ans = min(ans,abs(A-B))

print(ans)
import itertools



n = int(eval(input()))

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

acu = list(itertools.accumulate(w))

acu = [0] + acu

#print(acu)

ans = float("inf")

for i in range(1,n+1):

    ans = min(ans, abs(acu[i]-(acu[n]-acu[i])))

    #print(acu[i],acu[n]-acu[i])

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

import itertools

n = int(eval(input()))
w = list(map(int, input().split()))
acu = list(itertools.accumulate(w))
acu = [0] + acu
# print(acu)
ans = float("inf")
for i in range(1, n + 1):
    ans = min(ans, abs(acu[i] - (acu[n] - acu[i])))
    # print(acu[i],acu[n]-acu[i])
print(ans)

-N = int(eval(input())) -W = list(map(int, input().split())) -ans = sum(W) -for i in range(1, N): -    A = sum(W[0:i]) -    B = sum(W[i:]) -    ans = min(ans, abs(A - B)) +import itertools + +n = int(eval(input())) +w = list(map(int, input().split())) +acu = list(itertools.accumulate(w)) +acu = [0] + acu +# print(acu) +ans = float("inf") +for i in range(1, n + 1): +    ans = min(ans, abs(acu[i] - (acu[n] - acu[i]))) +    # print(acu[i],acu[n]-acu[i])