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


for i in range(n):
    a = sum(w[:i+1])
    b = sum(w[i+1:])
    if i == 0:
        s = abs(a-b)
    else:
        if abs(a-b) < s:
            s = abs(a-b)

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


for i in range(n):
    a = sum(w[:i+1])
    b = sum(w[i+1:])
    if i == 0:
        s = abs(a-b)
    else:
        if abs(a-b) < s:
            s = abs(a-b)

print(s)