n = int(eval(input()))

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

s = sum(a)

ans = 10**10

sunuke = 0

for i in range(n - 1):

    sunuke += a[i]

    ans = min(ans, abs(2 * sunuke - s))

print(ans)

n = int(eval(input()))

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

s = sum(a)

ans = 10**10

sunuke = 0

for i in range(n - 1):

    sunuke += a[i]

    ans = min(ans, abs(2 * sunuke - s))

print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
s = sum(a)
ans = 10**10
sunuke = 0
for i in range(n - 1):
    sunuke += a[i]
    ans = min(ans, abs(2 * sunuke - s))
print(ans)

n = int(eval(input()))
a = tuple(map(int, input().split()))
s = sum(a)
ans = 10**10
sunuke = 0
for i in range(n - 1):
    sunuke += a[i]
    ans = min(ans, abs(2 * sunuke - s))
print(ans)

-a = list(map(int, input().split())) +a = tuple(map(int, input().split()))