N = int(eval(input()))

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

P = A[0]

Q = sum(A[1:])

m = abs(P-Q)

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

  P += A[i]

  Q -= A[i]

  m = min(m, abs(P-Q))

print(m)
N = int(eval(input()))

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

S = sum(A)

T = [0]*(N+1)

for i in range(N):

  T[i+1] = T[i] + A[i]

print((min(abs(S-2*T[i]) for i in range(1, N))))
N = int(eval(input()))
A = list(map(int, input().split()))
P = A[0]
Q = sum(A[1:])
m = abs(P - Q)
for i in range(1, N - 1):
    P += A[i]
    Q -= A[i]
    m = min(m, abs(P - Q))
print(m)

N = int(eval(input()))
A = list(map(int, input().split()))
S = sum(A)
T = [0] * (N + 1)
for i in range(N):
    T[i + 1] = T[i] + A[i]
print((min(abs(S - 2 * T[i]) for i in range(1, N))))

-P = A[0] -Q = sum(A[1:]) -m = abs(P - Q) -for i in range(1, N - 1): -    P += A[i] -    Q -= A[i] -    m = min(m, abs(P - Q)) -print(m) +S = sum(A) +T = [0] * (N + 1) +for i in range(N): +    T[i + 1] = T[i] + A[i] +print((min(abs(S - 2 * T[i]) for i in range(1, N))))