import sys
input = sys.stdin.readline

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

n=int(input())
w = list(map(int,input().split()))
ans = sum(w)
for i in range(n):
    ans = min(ans,abs(sum(w[:i])-sum(w[i:])))
print(ans)