n = int(eval(input()))

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

ans = 999

for t in range(n):

	low = sum(lst_W[:t])

	high = sum(lst_W[t:])

	if ans > abs(high - low):

		ans = abs(high - low)

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

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

min = 1000000

for i in range(1, n):

    s1 = sum(w_lst[:i])

    s2 = sum(w_lst[i:])

    if abs(s1 - s2) < min:

        min = abs(s1 - s2)

print(min)
n = int(eval(input()))
lst_W = list(map(int, input().split()))
ans = 999
for t in range(n):
    low = sum(lst_W[:t])
    high = sum(lst_W[t:])
    if ans > abs(high - low):
        ans = abs(high - low)
print(ans)

n = int(eval(input()))
w_lst = list(map(int, input().split()))
min = 1000000
for i in range(1, n):
    s1 = sum(w_lst[:i])
    s2 = sum(w_lst[i:])
    if abs(s1 - s2) < min:
        min = abs(s1 - s2)
print(min)

-lst_W = list(map(int, input().split())) -ans = 999 -for t in range(n): -    low = sum(lst_W[:t]) -    high = sum(lst_W[t:]) -    if ans > abs(high - low): -        ans = abs(high - low) -print(ans) +w_lst = list(map(int, input().split())) +min = 1000000 +for i in range(1, n): +    s1 = sum(w_lst[:i]) +    s2 = sum(w_lst[i:]) +    if abs(s1 - s2) < min: +        min = abs(s1 - s2) +print(min)