n = int(eval(input()))

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

N = [0] * (n+1)

for i in range(1, n+1):

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



Max = N[-1]

ans = float("INF")

for i in range(1, n):

    if abs(N[i] - (Max-N[i])) < ans:

        ans =  abs(N[i] - (Max-N[i]))

print(ans)
n = int(eval(input()))

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

r = sum(A)-A[0]

l = A[0]

ans = abs(r-l)

for i in range(1,len(A)-1):

    r -= A[i]

    l += A[i]

    ans = min(ans, abs(l-r))

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
N = [0] * (n + 1)
for i in range(1, n + 1):
    N[i] += N[i - 1] + a[i - 1]
Max = N[-1]
ans = float("INF")
for i in range(1, n):
    if abs(N[i] - (Max - N[i])) < ans:
        ans = abs(N[i] - (Max - N[i]))
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
r = sum(A) - A[0]
l = A[0]
ans = abs(r - l)
for i in range(1, len(A) - 1):
    r -= A[i]
    l += A[i]
    ans = min(ans, abs(l - r))
print(ans)

-a = list(map(int, input().split())) -N = [0] * (n + 1) -for i in range(1, n + 1): -    N[i] += N[i - 1] + a[i - 1] -Max = N[-1] -ans = float("INF") -for i in range(1, n): -    if abs(N[i] - (Max - N[i])) < ans: -        ans = abs(N[i] - (Max - N[i])) +A = list(map(int, input().split())) +r = sum(A) - A[0] +l = A[0] +ans = abs(r - l) +for i in range(1, len(A) - 1): +    r -= A[i] +    l += A[i] +    ans = min(ans, abs(l - r))