N = int(eval(input()))

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



S = [0]*(N+1)

for i in range(N):

    S[i+1] += S[i] + A[i]

    

ans = 10**12

for i in range(N-1):

    ans = min(ans, abs(S[i+1]-(S[N]-S[i+1])))

    

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

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



for i in range(N-1):

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



ans = 10**15

for i in range(N-1):

    ans = min(ans, abs(A[N-1]-2*A[i]))

print(ans)
N = int(eval(input()))
A = [int(a) for a in input().split()]
S = [0] * (N + 1)
for i in range(N):
    S[i + 1] += S[i] + A[i]
ans = 10**12
for i in range(N - 1):
    ans = min(ans, abs(S[i + 1] - (S[N] - S[i + 1])))
print(ans)

N = int(eval(input()))
A = [int(a) for a in input().split()]
for i in range(N - 1):
    A[i + 1] += A[i]
ans = 10**15
for i in range(N - 1):
    ans = min(ans, abs(A[N - 1] - 2 * A[i]))
print(ans)

-S = [0] * (N + 1) -for i in range(N): -    S[i + 1] += S[i] + A[i] -ans = 10**12 -    ans = min(ans, abs(S[i + 1] - (S[N] - S[i + 1]))) +    A[i + 1] += A[i] +ans = 10**15 +for i in range(N - 1): +    ans = min(ans, abs(A[N - 1] - 2 * A[i]))