N = int(eval(input()))

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

s = a[:1]

t = a[1:]

x = sum(s)

y = sum(t)

if x==y:

  ans = 0

else:

  ans = abs(x-y)



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

  x += a[i]

  y -= a[i]

  if x==y:

    ans = 0

    break

  elif abs(x-y)<ans:

    ans = abs(x-y)

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

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

x = A[0]

y = sum(A[1:])

ans = abs(x - y)

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

    a = A[i]

    x += a

    y -= a

    dif = abs(x - y)

    if dif < ans:

        ans = dif

print(ans)
N = int(eval(input()))
a = list(map(int, input().split()))
s = a[:1]
t = a[1:]
x = sum(s)
y = sum(t)
if x == y:
    ans = 0
else:
    ans = abs(x - y)
for i in range(1, N - 1):
    x += a[i]
    y -= a[i]
    if x == y:
        ans = 0
        break
    elif abs(x - y) < ans:
        ans = abs(x - y)
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
x = A[0]
y = sum(A[1:])
ans = abs(x - y)
for i in range(1, N - 1):
    a = A[i]
    x += a
    y -= a
    dif = abs(x - y)
    if dif < ans:
        ans = dif
print(ans)

-a = list(map(int, input().split())) -s = a[:1] -t = a[1:] -x = sum(s) -y = sum(t) -if x == y: -    ans = 0 -else: -    ans = abs(x - y) +A = list(map(int, input().split())) +x = A[0] +y = sum(A[1:]) +ans = abs(x - y) -    x += a[i] -    y -= a[i] -    if x == y: -        ans = 0 -        break -    elif abs(x - y) < ans: -        ans = abs(x - y) +    a = A[i] +    x += a +    y -= a +    dif = abs(x - y) +    if dif < ans: +        ans = dif