n=int(input()) 
c=list(map(int, input().split()))
t = sum(c)
k = 0
ans =sum(c)

for i in c:
    t -= i
    k += i
    ans = min(abs(t-k),ans)
print(ans) n=int(input()) n int(input()) int input() input c=list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split t = sum(c) t sum(c) sum c k = 0 k 0 ans =sum(c) ans sum(c) sum c for i in c:
    t -= i
    k += i
    ans = min(abs(t-k),ans) i c t -= i t i k += i k i ans = min(abs(t-k),ans) ans min(abs(t-k),ans) min abs(t-k) abs t-k t k ans print(ans) print ans k = 0 0 k k += i i k ans =sum(c) sum(c) ans t -= i i t ans = min(abs(t-k),ans) min(abs(t-k),ans) ans c=list(map(int, input().split())) list(map(int, input().split())) c n=int(input()) int(input()) n t = sum(c) sum(c) t
n=int(input()) 
c=list(map(int, input().split()))
t = sum(c)
k = 0
ans =sum(c)

for i in c:
    t -= i
    k += i
    ans = min(abs(t-k),ans)
print(ans)