# coding: utf-8
# Your code here!
N = int(input())
W = list(map(int,input().split()))
S = sum(W)
ans = float('inf')
for i in range(N):
    l = sum(W[:i+1])
    r = S - l
    ans = min(ans, abs(l-r))

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 S = sum(W) S sum(W) sum W ans = float('inf') ans float('inf') float 'inf' for i in range(N):
    l = sum(W[:i+1])
    r = S - l
    ans = min(ans, abs(l-r)) i range(N) range N l = sum(W[:i+1]) l sum(W[:i+1]) sum W[:i+1] W :i+1 i+1 i 1 r = S - l r S - l S l 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 ans = float('inf') float('inf') ans W = list(map(int,input().split())) list(map(int,input().split())) W ans = min(ans, abs(l-r)) min(ans, abs(l-r)) ans l = sum(W[:i+1]) sum(W[:i+1]) l S = sum(W) sum(W) S N = int(input()) int(input()) N r = S - l S - l r
# coding: utf-8
# Your code here!
N = int(input())
W = list(map(int,input().split()))
S = sum(W)
ans = float('inf')
for i in range(N):
    l = sum(W[:i+1])
    r = S - l
    ans = min(ans, abs(l-r))

print(ans)