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

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

sl = [0]*N

sl[0] = a[0]

for i in range(N-1):

  sl[i+1] = sl[i]+a[i+1]

sr = [0]*N

sr[N-1] = a[N-1]

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

  sr[i-1] = sr[i]+a[i-1]

r = abs(sl[0]-sr[1])

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

  r = min(r, abs(sl[i]-sr[i+1]))

print(r)
N, = list(map(int, input().split()))

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

x = a[0]

y = sum(a) - a[0]

r = abs(x-y)

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

  x += ai

  y -= ai

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

print(r)
(N,) = list(map(int, input().split()))
a = list(map(int, input().split()))
sl = [0] * N
sl[0] = a[0]
for i in range(N - 1):
    sl[i + 1] = sl[i] + a[i + 1]
sr = [0] * N
sr[N - 1] = a[N - 1]
for i in range(N - 1, 0, -1):
    sr[i - 1] = sr[i] + a[i - 1]
r = abs(sl[0] - sr[1])
for i in range(1, N - 1):
    r = min(r, abs(sl[i] - sr[i + 1]))
print(r)

(N,) = list(map(int, input().split()))
a = list(map(int, input().split()))
x = a[0]
y = sum(a) - a[0]
r = abs(x - y)
for ai in a[1 : N - 1]:
    x += ai
    y -= ai
    r = min(r, abs(x - y))
print(r)

-sl = [0] * N -sl[0] = a[0] -for i in range(N - 1): -    sl[i + 1] = sl[i] + a[i + 1] -sr = [0] * N -sr[N - 1] = a[N - 1] -for i in range(N - 1, 0, -1): -    sr[i - 1] = sr[i] + a[i - 1] -r = abs(sl[0] - sr[1]) -for i in range(1, N - 1): -    r = min(r, abs(sl[i] - sr[i + 1])) +x = a[0] +y = sum(a) - a[0] +r = abs(x - y) +for ai in a[1 : N - 1]: +    x += ai +    y -= ai +    r = min(r, abs(x - y))