N = int(eval(input()))

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



x = sum(A)

y = 0

res = 10 ** 18



for i in range(N - 1):

    x -= A[i]

    y += A[i]

    res = min(res, abs(x - y))



print(res)

from itertools import accumulate

N = int(eval(input()))

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

Acum = list(accumulate(A))



ans = 10 ** 20



for a in Acum[:-1]:

    snuke = a

    arai = Acum[-1] - a

    ans = min(ans, abs(snuke - arai))

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
x = sum(A)
y = 0
res = 10**18
for i in range(N - 1):
    x -= A[i]
    y += A[i]
    res = min(res, abs(x - y))
print(res)

from itertools import accumulate

N = int(eval(input()))
A = list(map(int, input().split()))
Acum = list(accumulate(A))
ans = 10**20
for a in Acum[:-1]:
    snuke = a
    arai = Acum[-1] - a
    ans = min(ans, abs(snuke - arai))
print(ans)

+from itertools import accumulate + -x = sum(A) -y = 0 -res = 10**18 -for i in range(N - 1): -    x -= A[i] -    y += A[i] -    res = min(res, abs(x - y)) -print(res) +Acum = list(accumulate(A)) +ans = 10**20 +for a in Acum[:-1]: +    snuke = a +    arai = Acum[-1] - a +    ans = min(ans, abs(snuke - arai)) +print(ans)