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

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

ans = sum(w)
for i in range(n):
  s1 = sum(w[:i+1])
  s2 = sum(w[i+1:n])
  ans = min(ans, abs(s2-s1))
  
print(ans)