n = int(input())
w = list(map(int,input().split()))
min_n = 1000 
for m in range(n):
    sum_min = 0
    sum_max = 0
    sum_n = 0
    for i in range(m):
        sum_min += w[i]
    for j in range(m,n):
        sum_max += w[j]
    sum_n = abs(sum_max - sum_min)
    if min_n > sum_n:
        min_n = sum_n
print(min_n) 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 min_n = 1000 min_n 1000 for m in range(n):
    sum_min = 0
    sum_max = 0
    sum_n = 0
    for i in range(m):
        sum_min += w[i]
    for j in range(m,n):
        sum_max += w[j]
    sum_n = abs(sum_max - sum_min)
    if min_n > sum_n:
        min_n = sum_n m range(n) range n sum_min = 0 sum_min 0 sum_max = 0 sum_max 0 sum_n = 0 sum_n 0 for i in range(m):
        sum_min += w[i]
     i range(m) range m sum_min += w[i] sum_min w[i] w i for j in range(m,n):
        sum_max += w[j]
     j range(m,n) range m n sum_max += w[j] sum_max w[j] w j sum_n = abs(sum_max - sum_min) sum_n abs(sum_max - sum_min) abs sum_max - sum_min sum_max sum_min if min_n > sum_n:
        min_n = sum_n min_n > sum_n min_n sum_n min_n = sum_n min_n sum_n print(min_n) print min_n sum_n = abs(sum_max - sum_min) abs(sum_max - sum_min) sum_n sum_max = 0 0 sum_max sum_max += w[j] w[j] sum_max sum_n = 0 0 sum_n min_n = 1000 1000 min_n min_n = sum_n sum_n min_n sum_min = 0 0 sum_min n = int(input()) int(input()) n w = list(map(int,input().split())) list(map(int,input().split())) w sum_min += w[i] w[i] sum_min
n = int(input())
w = list(map(int,input().split()))
min_n = 1000 
for m in range(n):
    sum_min = 0
    sum_max = 0
    sum_n = 0
    for i in range(m):
        sum_min += w[i]
    for j in range(m,n):
        sum_max += w[j]
    sum_n = abs(sum_max - sum_min)
    if min_n > sum_n:
        min_n = sum_n
print(min_n)