N = int(eval(input()))

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



s = [0]

for i in range(N):

    s.append(s[-1] + src[i])



ans = float('inf')

for i in range(N-1):

    a = s[i+1]

    b = s[-1] - s[i+1]

    df = abs(a-b)

    ans = min(ans, df)

print(ans)

N = int(eval(input()))

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

s = sum(src)

ans = float('inf')

tmp = 0

for i in range(N-1):

    tmp += src[i]

    rem = s - tmp

    ans = min(ans, abs(tmp - rem))

print(ans)

N = int(eval(input()))
src = list(map(int, input().split()))
s = [0]
for i in range(N):
    s.append(s[-1] + src[i])
ans = float("inf")
for i in range(N - 1):
    a = s[i + 1]
    b = s[-1] - s[i + 1]
    df = abs(a - b)
    ans = min(ans, df)
print(ans)

N = int(eval(input()))
src = list(map(int, input().split()))
s = sum(src)
ans = float("inf")
tmp = 0
for i in range(N - 1):
    tmp += src[i]
    rem = s - tmp
    ans = min(ans, abs(tmp - rem))
print(ans)

-s = [0] -for i in range(N): -    s.append(s[-1] + src[i]) +s = sum(src) +tmp = 0 -    a = s[i + 1] -    b = s[-1] - s[i + 1] -    df = abs(a - b) -    ans = min(ans, df) +    tmp += src[i] +    rem = s - tmp +    ans = min(ans, abs(tmp - rem))