n = int(input())
w = list(map(int, input().split()))

t = 0
s = sum(w)
ans = sum(w)
for i in range(n):
  t += w[i]
  s -= w[i]
  if abs(s-t) < ans:
    ans = abs(s-t)
print(ans) 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 t = 0 t 0 s = sum(w) s sum(w) sum w ans = sum(w) ans sum(w) sum w for i in range(n):
  t += w[i]
  s -= w[i]
  if abs(s-t) < ans:
    ans = abs(s-t) i range(n) range n t += w[i] t w[i] w i s -= w[i] s w[i] w i if abs(s-t) < ans:
    ans = abs(s-t) abs(s-t) < ans abs(s-t) abs s-t s t ans ans = abs(s-t) ans abs(s-t) abs s-t s t print(ans) print ans s = sum(w) sum(w) s w = list(map(int, input().split())) list(map(int, input().split())) w s -= w[i] w[i] s ans = sum(w) sum(w) ans ans = abs(s-t) abs(s-t) ans n = int(input()) int(input()) n t = 0 0 t t += w[i] w[i] t
n = int(input())
w = list(map(int, input().split()))

t = 0
s = sum(w)
ans = sum(w)
for i in range(n):
  t += w[i]
  s -= w[i]
  if abs(s-t) < ans:
    ans = abs(s-t)
print(ans)