n = int(eval(input()))

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

b = sum(a)

c = 0

ans = float("Inf")

for i in range(n-1):

    c += a[i]

    b -= a[i]

    ans = min(ans,abs(b-c))

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

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

b = sum(a)

c = 0

ans = float("Inf")

for i in range(n-1):

    c += a[i]

    ans = min(ans,abs(b-2*c))

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
b = sum(a)
c = 0
ans = float("Inf")
for i in range(n - 1):
    c += a[i]
    b -= a[i]
    ans = min(ans, abs(b - c))
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
b = sum(a)
c = 0
ans = float("Inf")
for i in range(n - 1):
    c += a[i]
    ans = min(ans, abs(b - 2 * c))
print(ans)

-    b -= a[i] -    ans = min(ans, abs(b - c)) +    ans = min(ans, abs(b - 2 * c))