n = int(eval(input()))

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

a = sum(l)



min_s = float('inf')

x = 0

for i in range(n-1):

  x += l[i]

  s = abs(a-2*x)

  if s <= min_s:

    min_s = s

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

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



S = sum(A)



from itertools import accumulate

C = [0]+A

C = list(accumulate(C))

ans = 10**18

for i in range(1, n):

    s = C[i]

    a = S-s

    ans = min(ans, abs(s-a))

print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
a = sum(l)
min_s = float("inf")
x = 0
for i in range(n - 1):
    x += l[i]
    s = abs(a - 2 * x)
    if s <= min_s:
        min_s = s
print(min_s)

n = int(eval(input()))
A = list(map(int, input().split()))
S = sum(A)
from itertools import accumulate

C = [0] + A
C = list(accumulate(C))
ans = 10**18
for i in range(1, n):
    s = C[i]
    a = S - s
    ans = min(ans, abs(s - a))
print(ans)

-l = list(map(int, input().split())) -a = sum(l) -min_s = float("inf") -x = 0 -for i in range(n - 1): -    x += l[i] -    s = abs(a - 2 * x) -    if s <= min_s: -        min_s = s -print(min_s) +A = list(map(int, input().split())) +S = sum(A) +from itertools import accumulate + +C = [0] + A +C = list(accumulate(C)) +ans = 10**18 +for i in range(1, n): +    s = C[i] +    a = S - s +    ans = min(ans, abs(s - a)) +print(ans)