n = int(input())
w = list(map(int, input().split()))
ans = float('inf')
s1 = 0
s2 = sum(w)
for t in range(0,n):
    s1 += w[t]
    s2 -= w[t]
    ans = min(ans, abs(s1-s2))
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 = float('inf') ans float('inf') float 'inf' s1 = 0 s1 0 s2 = sum(w) s2 sum(w) sum w for t in range(0,n):
    s1 += w[t]
    s2 -= w[t]
    ans = min(ans, abs(s1-s2)) t range(0,n) range 0 n s1 += w[t] s1 w[t] w t s2 -= w[t] s2 w[t] w t ans = min(ans, abs(s1-s2)) ans min(ans, abs(s1-s2)) min ans abs(s1-s2) abs s1-s2 s1 s2 print(ans) print ans ans = float('inf') float('inf') ans ans = min(ans, abs(s1-s2)) min(ans, abs(s1-s2)) ans n = int(input()) int(input()) n s1 += w[t] w[t] s1 s1 = 0 0 s1 s2 = sum(w) sum(w) s2 w = list(map(int, input().split())) list(map(int, input().split())) w s2 -= w[t] w[t] s2
n = int(input())
w = list(map(int, input().split()))
ans = float('inf')
s1 = 0
s2 = sum(w)
for t in range(0,n):
    s1 += w[t]
    s2 -= w[t]
    ans = min(ans, abs(s1-s2))
print(ans)