N = int(eval(input()))

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



cum_sum = [0]*N

cum_sum[0] = a[0]



for i in range(1,N):

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



res = 10**15

for i in range(N-1):

	x = cum_sum[i]

	y = cum_sum[N-1] - cum_sum[i]

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



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

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



x = a[0]

y = sum(a[1:])

res = abs(x - y)



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

	x += a[i]

	y -= a[i]

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



print(res)
N = int(eval(input()))
a = list(map(int, input().split()))
cum_sum = [0] * N
cum_sum[0] = a[0]
for i in range(1, N):
    cum_sum[i] = cum_sum[i - 1] + a[i]
res = 10**15
for i in range(N - 1):
    x = cum_sum[i]
    y = cum_sum[N - 1] - cum_sum[i]
    res = min(res, abs(x - y))
print(res)

N = int(eval(input()))
a = list(map(int, input().split()))
x = a[0]
y = sum(a[1:])
res = abs(x - y)
for i in range(1, N - 1):
    x += a[i]
    y -= a[i]
    res = min(res, abs(x - y))
print(res)

-cum_sum = [0] * N -cum_sum[0] = a[0] -for i in range(1, N): -    cum_sum[i] = cum_sum[i - 1] + a[i] -res = 10**15 -for i in range(N - 1): -    x = cum_sum[i] -    y = cum_sum[N - 1] - cum_sum[i] +x = a[0] +y = sum(a[1:]) +res = abs(x - y) +for i in range(1, N - 1): +    x += a[i] +    y -= a[i]