n=int(input())
w=[int(x) for x in input().rstrip().split()]
SUM=sum(w)

now=0
ans=float('inf')
for i in w:
  now+=i
  ans=min(abs(now-(SUM-now)),ans)
print(ans) n=int(input()) n int(input()) int input() input int(x) for x in input().rstrip().split() for x in input().rstrip().split() x input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split for x in input().rstrip().split() int(x) int x w=[int(x) for x in input().rstrip().split()] w [int(x) for x in input().rstrip().split()] SUM=sum(w) SUM sum(w) sum w now=0 now 0 ans=float('inf') ans float('inf') float 'inf' for i in w:
  now+=i
  ans=min(abs(now-(SUM-now)),ans) i w now+=i now i ans=min(abs(now-(SUM-now)),ans) ans min(abs(now-(SUM-now)),ans) min abs(now-(SUM-now)) abs now-(SUM-now) now SUM-now SUM now ans print(ans) print ans n=int(input()) int(input()) n w=[int(x) for x in input().rstrip().split()] [int(x) for x in input().rstrip().split()] w ans=float('inf') float('inf') ans ans=min(abs(now-(SUM-now)),ans) min(abs(now-(SUM-now)),ans) ans SUM=sum(w) sum(w) SUM now+=i i now now=0 0 now
n=int(input())
w=[int(x) for x in input().rstrip().split()]
SUM=sum(w)

now=0
ans=float('inf')
for i in w:
  now+=i
  ans=min(abs(now-(SUM-now)),ans)
print(ans)
