N = int(eval(input()))

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

tot = sum(A)

B = [0 for _ in range(N-1)]

cnt = A[0]

for i in range(1,N):

    B[i-1] = abs(tot-2*cnt)

    cnt += A[i]

print((min(B)))
N = int(eval(input()))

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

tot = sum(A)

B = [0 for _ in range(N+1)]

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

    B[i] = B[i-1]+A[i-1]

cmin = abs(tot-2*B[1])

for i in range(2,N):

    cmin = min(cmin,abs(tot-2*B[i]))

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

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

-B = [0 for _ in range(N - 1)] -cnt = A[0] -for i in range(1, N): -    B[i - 1] = abs(tot - 2 * cnt) -    cnt += A[i] -print((min(B))) +B = [0 for _ in range(N + 1)] +for i in range(1, N + 1): +    B[i] = B[i - 1] + A[i - 1] +cmin = abs(tot - 2 * B[1]) +for i in range(2, N): +    cmin = min(cmin, abs(tot - 2 * B[i])) +print(cmin)