N = int(input())
W = list(map(int, input().split()))

ttl = sum(W)
s = []
min = ttl

for i in range(len(W)):
    s.append(W[i])
    s2 = ttl - sum(s)
    if abs(sum(s) - s2) < min:
        min = abs(sum(s) - s2)
        
print(min) 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 ttl = sum(W) ttl sum(W) sum W s = [] s [] min = ttl min ttl for i in range(len(W)):
    s.append(W[i])
    s2 = ttl - sum(s)
    if abs(sum(s) - s2) < min:
        min = abs(sum(s) - s2)
         i range(len(W)) range len(W) len W s.append(W[i]) s.append s append W[i] W i s2 = ttl - sum(s) s2 ttl - sum(s) ttl sum(s) sum s if abs(sum(s) - s2) < min:
        min = abs(sum(s) - s2)
         abs(sum(s) - s2) < min abs(sum(s) - s2) abs sum(s) - s2 sum(s) sum s s2 min min = abs(sum(s) - s2) min abs(sum(s) - s2) abs sum(s) - s2 sum(s) sum s s2 print(min) print min N = int(input()) int(input()) N s2 = ttl - sum(s) ttl - sum(s) s2 W = list(map(int, input().split())) list(map(int, input().split())) W s = [] [] s min = abs(sum(s) - s2) abs(sum(s) - s2) min min = ttl ttl min ttl = sum(W) sum(W) ttl
N = int(input())
W = list(map(int, input().split()))

ttl = sum(W)
s = []
min = ttl

for i in range(len(W)):
    s.append(W[i])
    s2 = ttl - sum(s)
    if abs(sum(s) - s2) < min:
        min = abs(sum(s) - s2)
        
print(min)