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,*a=list(map(int,open(0).read().split()))

s=sum(a)

c=0

m=[]

for b in a:c+=b;m+=abs(c+c-s),

print((min(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, *a = list(map(int, open(0).read().split()))
s = sum(a)
c = 0
m = []
for b in a:
    c += b
    m += (abs(c + c - s),)
print((min(m)))

-for i in range(1, n): -    a[i] += a[i - 1] -print((min(abs(t * 2 - s) for t in a))) +c = 0 +m = [] +for b in a: +    c += b +    m += (abs(c + c - s),) +print((min(m)))