N = int(eval(input()))

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



s = sum(A)

B = [0]

for i in range(N):

    B.append(B[i] + A[i])



ans = float('inf')

for i in range(1, N):

    ans = min(ans, abs(s-(2*B[i])))



print(ans)

N = int(eval(input()))

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



s = sum(A)

B = [0]

for i in range(N):

    B.append(B[i] + A[i])



ans = float('inf')

for i in range(1, N):

    _ans = ans

    ans = min(ans, abs(B[i] - (s - B[i])))

    if ans > _ans:

        break



print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
s = sum(A)
B = [0]
for i in range(N):
    B.append(B[i] + A[i])
ans = float("inf")
for i in range(1, N):
    ans = min(ans, abs(s - (2 * B[i])))
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
s = sum(A)
B = [0]
for i in range(N):
    B.append(B[i] + A[i])
ans = float("inf")
for i in range(1, N):
    _ans = ans
    ans = min(ans, abs(B[i] - (s - B[i])))
    if ans > _ans:
        break
print(ans)

-    ans = min(ans, abs(s - (2 * B[i]))) +    _ans = ans +    ans = min(ans, abs(B[i] - (s - B[i]))) +    if ans > _ans: +        break