N = int(eval(input()))

A = [int(i) for i in input().split()]



su = sum(A)

x = 0

mi = 1e15

for a in A[:-1]:

    x += a

    mi = min(mi, abs(su - 2 * x))

print(mi)
from itertools import accumulate



N = int(eval(input()))

A = [int(i) for i in input().split()]



*B, su = list(accumulate(A))

print((min(abs(su - 2 * b) for b in B)))

N = int(eval(input()))
A = [int(i) for i in input().split()]
su = sum(A)
x = 0
mi = 1e15
for a in A[:-1]:
    x += a
    mi = min(mi, abs(su - 2 * x))
print(mi)

from itertools import accumulate

N = int(eval(input()))
A = [int(i) for i in input().split()]
*B, su = list(accumulate(A))
print((min(abs(su - 2 * b) for b in B)))

+from itertools import accumulate + -su = sum(A) -x = 0 -mi = 1e15 -for a in A[:-1]: -    x += a -    mi = min(mi, abs(su - 2 * x)) -print(mi) +*B, su = list(accumulate(A)) +print((min(abs(su - 2 * b) for b in B)))