import numpy as np



N = int(eval(input()))

A = [int(x) for x in input().split()]

A = np.array(A)



Acum = A.cumsum()

L = Acum[:-1]

R = Acum[-1] - L

print((abs(L-R).min()))
import itertools



N = int(eval(input()))

A = [int(x) for x in input().split()]



reg = 10**12

Acum = list(itertools.accumulate(A))

for i in range(N):

    L = Acum[i]

    R = Acum[-1] - L

    tmp = abs(L-R)

    reg = min(reg, tmp)

print(reg)
import numpy as np

N = int(eval(input()))
A = [int(x) for x in input().split()]
A = np.array(A)
Acum = A.cumsum()
L = Acum[:-1]
R = Acum[-1] - L
print((abs(L - R).min()))

import itertools

N = int(eval(input()))
A = [int(x) for x in input().split()]
reg = 10**12
Acum = list(itertools.accumulate(A))
for i in range(N):
    L = Acum[i]
    R = Acum[-1] - L
    tmp = abs(L - R)
    reg = min(reg, tmp)
print(reg)

-import numpy as np +import itertools -A = np.array(A) -Acum = A.cumsum() -L = Acum[:-1] -R = Acum[-1] - L -print((abs(L - R).min())) +reg = 10**12 +Acum = list(itertools.accumulate(A)) +for i in range(N): +    L = Acum[i] +    R = Acum[-1] - L +    tmp = abs(L - R) +    reg = min(reg, tmp) +print(reg)