N = int(eval(input()))

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

s = sum(src)

ans = float('inf')

tmp = 0

for i in range(N-1):

    tmp += src[i]

    rem = s - tmp

    ans = min(ans, abs(tmp - rem))

print(ans)

from itertools import accumulate as ac

N = int(eval(input()))

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

acum = list(ac(src))

ans = float('inf')

for i in range(N-1):

    ans = min(ans, abs(acum[i] - (acum[-1]-acum[i])))

print(ans)
N = int(eval(input()))
src = list(map(int, input().split()))
s = sum(src)
ans = float("inf")
tmp = 0
for i in range(N - 1):
    tmp += src[i]
    rem = s - tmp
    ans = min(ans, abs(tmp - rem))
print(ans)

from itertools import accumulate as ac

N = int(eval(input()))
src = list(map(int, input().split()))
acum = list(ac(src))
ans = float("inf")
for i in range(N - 1):
    ans = min(ans, abs(acum[i] - (acum[-1] - acum[i])))
print(ans)

+from itertools import accumulate as ac + -s = sum(src) +acum = list(ac(src)) -tmp = 0 -    tmp += src[i] -    rem = s - tmp -    ans = min(ans, abs(tmp - rem)) +    ans = min(ans, abs(acum[i] - (acum[-1] - acum[i])))