n = int(input())
w = list(map(int,input().split()))
s = sum(w)
g = 10**5
cnt = 0
for i in range(n):
    cnt += w[i]
    if abs(s-cnt*2) <= g:
        g = abs(s-cnt*2)
        ans = abs(s-cnt*2)
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 g = 10**5 g 10**5 10 5 cnt = 0 cnt 0 for i in range(n):
    cnt += w[i]
    if abs(s-cnt*2) <= g:
        g = abs(s-cnt*2)
        ans = abs(s-cnt*2) i range(n) range n cnt += w[i] cnt w[i] w i if abs(s-cnt*2) <= g:
        g = abs(s-cnt*2)
        ans = abs(s-cnt*2) abs(s-cnt*2) <= g abs(s-cnt*2) abs s-cnt*2 s cnt*2 cnt 2 g g = abs(s-cnt*2) g abs(s-cnt*2) abs s-cnt*2 s cnt*2 cnt 2 ans = abs(s-cnt*2) ans abs(s-cnt*2) abs s-cnt*2 s cnt*2 cnt 2 print(ans) print ans cnt = 0 0 cnt s = sum(w) sum(w) s g = abs(s-cnt*2) abs(s-cnt*2) g g = 10**5 10**5 g cnt += w[i] w[i] cnt w = list(map(int,input().split())) list(map(int,input().split())) w ans = abs(s-cnt*2) abs(s-cnt*2) ans n = int(input()) int(input()) n
n = int(input())
w = list(map(int,input().split()))
s = sum(w)
g = 10**5
cnt = 0
for i in range(n):
    cnt += w[i]
    if abs(s-cnt*2) <= g:
        g = abs(s-cnt*2)
        ans = abs(s-cnt*2)
print(ans)