from itertools import accumulate



N = int(eval(input()))

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



ans = 10**9

for i in range(N - 1):

    ans = min(ans, abs(W[N - 1] - W[i]*2))

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

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

s1 = 0

s2 = sum(W)



ans = 10**9

for w in W:

    s1 += w

    s2 -= w

    ans = min(ans, abs(s1 -s2))



print(ans)

from itertools import accumulate

N = int(eval(input()))
W = list(accumulate([int(x) for x in input().split()]))
ans = 10**9
for i in range(N - 1):
    ans = min(ans, abs(W[N - 1] - W[i] * 2))
print(ans)

N = int(eval(input()))
W = [int(x) for x in input().split()]
s1 = 0
s2 = sum(W)
ans = 10**9
for w in W:
    s1 += w
    s2 -= w
    ans = min(ans, abs(s1 - s2))
print(ans)

-from itertools import accumulate - -W = list(accumulate([int(x) for x in input().split()])) +W = [int(x) for x in input().split()] +s1 = 0 +s2 = sum(W) -for i in range(N - 1): -    ans = min(ans, abs(W[N - 1] - W[i] * 2)) +for w in W: +    s1 += w +    s2 -= w +    ans = min(ans, abs(s1 - s2))