n=int(eval(input()))

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



ans=n*10**9



b=[0]

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

    b.append(a[i-1]+b[i-1])



for i in range(n-1):

    t_ans=abs(b[i+1]-(b[-1]-b[i+1]))

    ans=min(ans,t_ans)



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

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



ans=n*10**9

t=sum(a)



s=0



for i in range(n-1):

#    s=sum(a[:i])

    s+=a[i]

    ans=min(ans,abs(t-2*s))

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
ans = n * 10**9
b = [0]
for i in range(1, n + 1):
    b.append(a[i - 1] + b[i - 1])
for i in range(n - 1):
    t_ans = abs(b[i + 1] - (b[-1] - b[i + 1]))
    ans = min(ans, t_ans)
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
ans = n * 10**9
t = sum(a)
s = 0
for i in range(n - 1):
    #    s=sum(a[:i])
    s += a[i]
    ans = min(ans, abs(t - 2 * s))
print(ans)

-b = [0] -for i in range(1, n + 1): -    b.append(a[i - 1] + b[i - 1]) +t = sum(a) +s = 0 -    t_ans = abs(b[i + 1] - (b[-1] - b[i + 1])) -    ans = min(ans, t_ans) +    #    s=sum(a[:i]) +    s += a[i] +    ans = min(ans, abs(t - 2 * s))