def sum(lista: list):

    soma = 0

    for l in lista:

        soma = soma + l

    return soma





n = int(eval(input()))

x = []

line = eval(input())

for _ in range(n):

    x = [int(t) for t in line.split()]

sum1 = []

sum2 = []

diff = []



for i in range(1, n):

    sum1 = sum(x[0:i])

    sum2 = sum(x[i:])

    diff.append(abs(sum1-sum2))

diff.sort()

print((diff[0]))
n = int(eval(input()))

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

balance = []

for i in range(1, n):

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

print((min(balance)))

def sum(lista: list):
    soma = 0
    for l in lista:
        soma = soma + l
    return soma


n = int(eval(input()))
x = []
line = eval(input())
for _ in range(n):
    x = [int(t) for t in line.split()]
sum1 = []
sum2 = []
diff = []
for i in range(1, n):
    sum1 = sum(x[0:i])
    sum2 = sum(x[i:])
    diff.append(abs(sum1 - sum2))
diff.sort()
print((diff[0]))

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

-def sum(lista: list): -    soma = 0 -    for l in lista: -        soma = soma + l -    return soma - - -x = [] -line = eval(input()) -for _ in range(n): -    x = [int(t) for t in line.split()] -sum1 = [] -sum2 = [] -diff = [] +w = [int(x) for x in input().split()] +balance = [] -    sum1 = sum(x[0:i]) -    sum2 = sum(x[i:]) -    diff.append(abs(sum1 - sum2)) -diff.sort() -print((diff[0])) +    balance.append(abs(sum(w[:i]) - sum(w[i:]))) +print((min(balance)))