n=int(eval(input()))

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

L=[A[0]]

R=[A[-1]]

for i in range(1,n-1):

    l=L[i-1]+A[i]

    L.append(l)

    r=R[i-1]+A[-(i+1)]

    R.append(r)

c=2*10**14

for i in range(n-1):

    s=abs(L[i]-R[-(i+1)])

    c=min(c,s)

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

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

X=sum(A)

x=0

c=2*10**14

for i in range(n-1):

    x+=A[i]

    s=abs(X-2*x)

    c=min(c,s)

print(c)
n = int(eval(input()))
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]
for i in range(1, n - 1):
    l = L[i - 1] + A[i]
    L.append(l)
    r = R[i - 1] + A[-(i + 1)]
    R.append(r)
c = 2 * 10**14
for i in range(n - 1):
    s = abs(L[i] - R[-(i + 1)])
    c = min(c, s)
print(c)

n = int(eval(input()))
A = list(map(int, input().split()))
X = sum(A)
x = 0
c = 2 * 10**14
for i in range(n - 1):
    x += A[i]
    s = abs(X - 2 * x)
    c = min(c, s)
print(c)

-L = [A[0]] -R = [A[-1]] -for i in range(1, n - 1): -    l = L[i - 1] + A[i] -    L.append(l) -    r = R[i - 1] + A[-(i + 1)] -    R.append(r) +X = sum(A) +x = 0 -    s = abs(L[i] - R[-(i + 1)]) +    x += A[i] +    s = abs(X - 2 * x)