N = int(eval(input()))

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

cums = [0]

for a in A:

    cums.append(cums[-1] + a)



ans = 10**20

for i in range(1,N):

    x = cums[i]

    y = cums[-1] - cums[i]

    ans = min(ans, abs(x-y))

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

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

cums = [0]

for a in A:

    cums.append(cums[-1] + a)

ans = float('inf')

for i in range(1,N):

    c = cums[i]

    ans = min(ans, abs(cums[-1]-c - c))

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)
ans = 10**20
for i in range(1, N):
    x = cums[i]
    y = cums[-1] - cums[i]
    ans = min(ans, abs(x - y))
print(ans)

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

-ans = 10**20 +ans = float("inf") -    x = cums[i] -    y = cums[-1] - cums[i] -    ans = min(ans, abs(x - y)) +    c = cums[i] +    ans = min(ans, abs(cums[-1] - c - c))