from itertools import accumulate
n=int(input())
w=list(map(int,input().split()))
tmp=0
l=list(accumulate(w))
ans=float("inf")
for i in range(n):
    tmp=abs(l[i]-(l[n-1]-l[i]))
    if tmp<ans:
        ans=tmp
print(ans) from itertools import accumulate n=int(input()) n int(input()) int input() input w=list(map(int,input().split())) w list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split tmp=0 tmp 0 l=list(accumulate(w)) l list(accumulate(w)) list accumulate(w) accumulate w ans=float("inf") ans float("inf") float "inf" for i in range(n):
    tmp=abs(l[i]-(l[n-1]-l[i]))
    if tmp<ans:
        ans=tmp i range(n) range n tmp=abs(l[i]-(l[n-1]-l[i])) tmp abs(l[i]-(l[n-1]-l[i])) abs l[i]-(l[n-1]-l[i]) l[i] l i l[n-1]-l[i] l[n-1] l n-1 n 1 l[i] l i if tmp<ans:
        ans=tmp tmp<ans tmp ans ans=tmp ans tmp print(ans) print ans ans=float("inf") float("inf") ans l=list(accumulate(w)) list(accumulate(w)) l ans=tmp tmp ans n=int(input()) int(input()) n tmp=0 0 tmp w=list(map(int,input().split())) list(map(int,input().split())) w tmp=abs(l[i]-(l[n-1]-l[i])) abs(l[i]-(l[n-1]-l[i])) tmp
from itertools import accumulate
n=int(input())
w=list(map(int,input().split()))
tmp=0
l=list(accumulate(w))
ans=float("inf")
for i in range(n):
    tmp=abs(l[i]-(l[n-1]-l[i]))
    if tmp<ans:
        ans=tmp
print(ans)