N = int(eval(input()))

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

acu = []

acu.append(A[0])

acu_r = []

acu_r.append(A[-1])

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

  acu.append(acu[-1] + A[i])

for i in range(N-2,0,-1):

  acu_r.append(acu_r[-1] + A[i])

#print(acu)

#print(acu_r)

ans = float("inf")

for i in range(N-1):

  ans = min(ans,abs(acu[i] - acu_r[N - (i + 2)]))

print(ans)



N = int(eval(input()))

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

ans = float("inf")

S = sum(A)

acu = []

acu.append(A[0])

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

  acu.append(acu[-1] + A[i])

for i in range(N-1):

  ans = min(ans,abs((S - acu[i]) - acu[i]))

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

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

+ans = float("inf") +S = sum(A) -acu_r = [] -acu_r.append(A[-1]) -for i in range(N - 2, 0, -1): -    acu_r.append(acu_r[-1] + A[i]) -# print(acu) -# print(acu_r) -ans = float("inf") -    ans = min(ans, abs(acu[i] - acu_r[N - (i + 2)])) +    ans = min(ans, abs((S - acu[i]) - acu[i]))