n=int(input())
h=list(map(int,input().split()))
a=sum(h)
tmp = 0
for i in range(n):
  tmp += h[i]
  a = min(a, abs(tmp - (sum(h)-tmp)))
print(a) n=int(input()) n int(input()) int input() input h=list(map(int,input().split())) h list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split a=sum(h) a sum(h) sum h tmp = 0 tmp 0 for i in range(n):
  tmp += h[i]
  a = min(a, abs(tmp - (sum(h)-tmp))) i range(n) range n tmp += h[i] tmp h[i] h i a = min(a, abs(tmp - (sum(h)-tmp))) a min(a, abs(tmp - (sum(h)-tmp))) min a abs(tmp - (sum(h)-tmp)) abs tmp - (sum(h)-tmp) tmp sum(h)-tmp sum(h) sum h tmp print(a) print a tmp = 0 0 tmp h=list(map(int,input().split())) list(map(int,input().split())) h a = min(a, abs(tmp - (sum(h)-tmp))) min(a, abs(tmp - (sum(h)-tmp))) a tmp += h[i] h[i] tmp a=sum(h) sum(h) a n=int(input()) int(input()) n
n=int(input())
h=list(map(int,input().split()))
a=sum(h)
tmp = 0
for i in range(n):
  tmp += h[i]
  a = min(a, abs(tmp - (sum(h)-tmp)))
print(a)