#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


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

total = sum(w)
sa = []
for i in range(n):
    #print(w[0:i+1])
    #print(w[i+1:n+1])
    s1 = sum(w[0:i+1])
    s2 = total - s1
    sa.append(abs(s1-s2))
#print(sa)
print(min(sa)) 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 total = sum(w) total sum(w) sum w sa = [] sa [] for i in range(n):
    #print(w[0:i+1])
    #print(w[i+1:n+1])
    s1 = sum(w[0:i+1])
    s2 = total - s1
    sa.append(abs(s1-s2))
#print(sa) i range(n) range n s1 = sum(w[0:i+1]) s1 sum(w[0:i+1]) sum w[0:i+1] w 0:i+1 0 i+1 i 1 s2 = total - s1 s2 total - s1 total s1 sa.append(abs(s1-s2)) sa.append sa append abs(s1-s2) abs s1-s2 s1 s2 print(min(sa)) print min(sa) min sa s2 = total - s1 total - s1 s2 sa = [] [] sa total = sum(w) sum(w) total w = list(map(int, input().split())) list(map(int, input().split())) w s1 = sum(w[0:i+1]) sum(w[0:i+1]) s1 n = int(input()) int(input()) n
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


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

total = sum(w)
sa = []
for i in range(n):
    #print(w[0:i+1])
    #print(w[i+1:n+1])
    s1 = sum(w[0:i+1])
    s2 = total - s1
    sa.append(abs(s1-s2))
#print(sa)
print(min(sa))
