n=int(eval(input()))

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

length=sum(a)

for i in range(1,n):a[i]+=a[i-1]

m=10**18

for i in range(n-1):

    left=a[i]

    right=length-left

    m=min(m,abs(left-right))

print(m)
n,*a=list(map(int,open(0).read().split()))

s=sum(a)

for i in range(1,n):a[i]+=a[i-1]

print((min(abs(t*2-s)for t in a)))
n = int(eval(input()))
(*a,) = list(map(int, input().split()))
length = sum(a)
for i in range(1, n):
    a[i] += a[i - 1]
m = 10**18
for i in range(n - 1):
    left = a[i]
    right = length - left
    m = min(m, abs(left - right))
print(m)

n, *a = list(map(int, open(0).read().split()))
s = sum(a)
for i in range(1, n):
    a[i] += a[i - 1]
print((min(abs(t * 2 - s) for t in a)))

-n = int(eval(input())) -(*a,) = list(map(int, input().split())) -length = sum(a) +n, *a = list(map(int, open(0).read().split())) +s = sum(a) -m = 10**18 -for i in range(n - 1): -    left = a[i] -    right = length - left -    m = min(m, abs(left - right)) -print(m) +print((min(abs(t * 2 - s) for t in a)))