from itertools import accumulate


def LI():
    return list(map(int, input().split()))


N = int(input())
W = LI()
total = sum(W)
Wsum = list(accumulate(W))
ans = 10000000
for i in range(N):
    ans = min(ans, abs(Wsum[i]-(total-Wsum[i])))
print(ans) from itertools import accumulate def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N = int(input()) N int(input()) int input() input W = LI() W LI() LI total = sum(W) total sum(W) sum W Wsum = list(accumulate(W)) Wsum list(accumulate(W)) list accumulate(W) accumulate W ans = 10000000 ans 10000000 for i in range(N):
    ans = min(ans, abs(Wsum[i]-(total-Wsum[i]))) i range(N) range N ans = min(ans, abs(Wsum[i]-(total-Wsum[i]))) ans min(ans, abs(Wsum[i]-(total-Wsum[i]))) min ans abs(Wsum[i]-(total-Wsum[i])) abs Wsum[i]-(total-Wsum[i]) Wsum[i] Wsum i total-Wsum[i] total Wsum[i] Wsum i print(ans) print ans W = LI() LI() W Wsum = list(accumulate(W)) list(accumulate(W)) Wsum ans = min(ans, abs(Wsum[i]-(total-Wsum[i]))) min(ans, abs(Wsum[i]-(total-Wsum[i]))) ans total = sum(W) sum(W) total N = int(input()) int(input()) N ans = 10000000 10000000 ans def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI
from itertools import accumulate


def LI():
    return list(map(int, input().split()))


N = int(input())
W = LI()
total = sum(W)
Wsum = list(accumulate(W))
ans = 10000000
for i in range(N):
    ans = min(ans, abs(Wsum[i]-(total-Wsum[i])))
print(ans)
