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

ans = abs(sum(w))
s1 = 0
s2 = sum(w)
for i in range(n-1):
    s1 += w[i]
    s2 -= w[i]
    m = abs(s2-s1)
    if m <= ans :
        ans = m
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 ans = abs(sum(w)) ans abs(sum(w)) abs sum(w) sum w s1 = 0 s1 0 s2 = sum(w) s2 sum(w) sum w for i in range(n-1):
    s1 += w[i]
    s2 -= w[i]
    m = abs(s2-s1)
    if m <= ans :
        ans = m i range(n-1) range n-1 n 1 s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i m = abs(s2-s1) m abs(s2-s1) abs s2-s1 s2 s1 if m <= ans :
        ans = m m <= ans m ans ans = m ans m print(ans) print ans w = list(map(int,input().split())) list(map(int,input().split())) w m = abs(s2-s1) abs(s2-s1) m ans = abs(sum(w)) abs(sum(w)) ans s1 += w[i] w[i] s1 n = int(input()) int(input()) n s2 -= w[i] w[i] s2 s2 = sum(w) sum(w) s2 ans = m m ans s1 = 0 0 s1
n = int(input())
w = list(map(int,input().split()))

ans = abs(sum(w))
s1 = 0
s2 = sum(w)
for i in range(n-1):
    s1 += w[i]
    s2 -= w[i]
    m = abs(s2-s1)
    if m <= ans :
        ans = m
print(ans)
