n=int(input())
w=[int(x) for x in input().split()]
r=sum(w)
l=0
ans=r
for i in range(n):
  l+=w[i]
  r-=w[i]
  ans=min(ans, abs(l-r))
print(ans) n=int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x w=[int(x) for x in input().split()] w [int(x) for x in input().split()] r=sum(w) r sum(w) sum w l=0 l 0 ans=r ans r for i in range(n):
  l+=w[i]
  r-=w[i]
  ans=min(ans, abs(l-r)) i range(n) range n l+=w[i] l w[i] w i r-=w[i] r w[i] w i ans=min(ans, abs(l-r)) ans min(ans, abs(l-r)) min ans abs(l-r) abs l-r l r print(ans) print ans l=0 0 l r=sum(w) sum(w) r l+=w[i] w[i] l w=[int(x) for x in input().split()] [int(x) for x in input().split()] w r-=w[i] w[i] r ans=r r ans ans=min(ans, abs(l-r)) min(ans, abs(l-r)) ans n=int(input()) int(input()) n
n=int(input())
w=[int(x) for x in input().split()]
r=sum(w)
l=0
ans=r
for i in range(n):
  l+=w[i]
  r-=w[i]
  ans=min(ans, abs(l-r))
print(ans)