# 累積和をととっといて比較

n = int(eval(input()))

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



ruiseki = [0 for _ in range(n)]

ruiseki[0] = arr[0]



for i in range(1, n):

    ruiseki[i] += ruiseki[i - 1] + arr[i]



inf = 10 ** 20

ans = inf



for i in range(n - 1):

    x = ruiseki[i]

    y = ruiseki[-1] - x

    ans = min(ans, abs(x - y))

print(ans)

# 累積和が見える

n = int(eval(input()))

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

ruiseki = [0 for _ in range(n)]

ruiseki[0] = a[0]

for i in range(1, n):

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



ans = 10 ** 16

for i in range(n-1):

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

  

print(ans)

# 累積和をととっといて比較
n = int(eval(input()))
arr = list(map(int, input().split()))
ruiseki = [0 for _ in range(n)]
ruiseki[0] = arr[0]
for i in range(1, n):
    ruiseki[i] += ruiseki[i - 1] + arr[i]
inf = 10**20
ans = inf
for i in range(n - 1):
    x = ruiseki[i]
    y = ruiseki[-1] - x
    ans = min(ans, abs(x - y))
print(ans)

# 累積和が見える
n = int(eval(input()))
a = list(map(int, input().split()))
ruiseki = [0 for _ in range(n)]
ruiseki[0] = a[0]
for i in range(1, n):
    ruiseki[i] = ruiseki[i - 1] + a[i]
ans = 10**16
for i in range(n - 1):
    ans = min(ans, abs(ruiseki[-1] - ruiseki[i] * 2))
print(ans)

-# 累積和をととっといて比較 +# 累積和が見える -arr = list(map(int, input().split())) +a = list(map(int, input().split())) -ruiseki[0] = arr[0] +ruiseki[0] = a[0] -    ruiseki[i] += ruiseki[i - 1] + arr[i] -inf = 10**20 -ans = inf +    ruiseki[i] = ruiseki[i - 1] + a[i] +ans = 10**16 -    x = ruiseki[i] -    y = ruiseki[-1] - x -    ans = min(ans, abs(x - y)) +    ans = min(ans, abs(ruiseki[-1] - ruiseki[i] * 2))