N = int(eval(input()))

a = [int(x) for x in input().split()]

ans = 10**9*N

front = 0

back = sum(a)

for i in range(N-1):

    front += a[i]

    back -= a[i]

    ans = min(ans, abs(front-back))

print(ans)
with open(0) as f:

    N, *a = list(map(int, f.read().split()))

score = -sum(a[1:]) + a[0]

ans = abs(score)

for x in a[1:N-1]:

    score += 2*x

    ans = min(ans, abs(score))

print(ans)
N = int(eval(input()))
a = [int(x) for x in input().split()]
ans = 10**9 * N
front = 0
back = sum(a)
for i in range(N - 1):
    front += a[i]
    back -= a[i]
    ans = min(ans, abs(front - back))
print(ans)

with open(0) as f:
    N, *a = list(map(int, f.read().split()))
score = -sum(a[1:]) + a[0]
ans = abs(score)
for x in a[1 : N - 1]:
    score += 2 * x
    ans = min(ans, abs(score))
print(ans)

-N = int(eval(input())) -a = [int(x) for x in input().split()] -ans = 10**9 * N -front = 0 -back = sum(a) -for i in range(N - 1): -    front += a[i] -    back -= a[i] -    ans = min(ans, abs(front - back)) +with open(0) as f: +    N, *a = list(map(int, f.read().split())) +score = -sum(a[1:]) + a[0] +ans = abs(score) +for x in a[1 : N - 1]: +    score += 2 * x +    ans = min(ans, abs(score))