n=int(eval(input()))

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

for i in range(1,n):

    a[i]+=a[i-1]

ABS=10**15

for i in range(n-1):

    ABS=min(abs(a[-1]-2*a[i]),ABS)

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

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

s=sum(a)

now=0

ans=10**14

for i in a[:n-1]:

    now+=i

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

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

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

-for i in range(1, n): -    a[i] += a[i - 1] -ABS = 10**15 -for i in range(n - 1): -    ABS = min(abs(a[-1] - 2 * a[i]), ABS) -print(ABS) +s = sum(a) +now = 0 +ans = 10**14 +for i in a[: n - 1]: +    now += i +    ans = min(abs(2 * now - s), ans) +print(ans)