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