n=int(input())
l=list(map(int,input().split()))
l_sum=sum(l)
ans=l_sum
c1=0
c2=0

for i in range(len(l)):
    c1=l_sum-sum(l[:i+1])
    c2=abs(c1-sum(l[:i+1]))

    if ans> c2:
        ans=c2
  
print(ans) n=int(input()) n int(input()) int input() input l=list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l_sum=sum(l) l_sum sum(l) sum l ans=l_sum ans l_sum c1=0 c1 0 c2=0 c2 0 for i in range(len(l)):
    c1=l_sum-sum(l[:i+1])
    c2=abs(c1-sum(l[:i+1]))

    if ans> c2:
        ans=c2
   i range(len(l)) range len(l) len l c1=l_sum-sum(l[:i+1]) c1 l_sum-sum(l[:i+1]) l_sum sum(l[:i+1]) sum l[:i+1] l :i+1 i+1 i 1 c2=abs(c1-sum(l[:i+1])) c2 abs(c1-sum(l[:i+1])) abs c1-sum(l[:i+1]) c1 sum(l[:i+1]) sum l[:i+1] l :i+1 i+1 i 1 if ans> c2:
        ans=c2
   ans> c2 ans c2 ans=c2 ans c2 print(ans) print ans c1=0 0 c1 c2=0 0 c2 ans=c2 c2 ans c1=l_sum-sum(l[:i+1]) l_sum-sum(l[:i+1]) c1 l_sum=sum(l) sum(l) l_sum ans=l_sum l_sum ans c2=abs(c1-sum(l[:i+1])) abs(c1-sum(l[:i+1])) c2 l=list(map(int,input().split())) list(map(int,input().split())) l n=int(input()) int(input()) n
n=int(input())
l=list(map(int,input().split()))
l_sum=sum(l)
ans=l_sum
c1=0
c2=0

for i in range(len(l)):
    c1=l_sum-sum(l[:i+1])
    c2=abs(c1-sum(l[:i+1]))

    if ans> c2:
        ans=c2
  
print(ans)