n = int(input())
list_w = [int(i) for i in input().split()]
tmp1 = 0
tmp2 = 0
ans = sum(list_w)
for i in range(0, len(list_w)):
    tmp1 = sum(list_w[:i + 1])
    tmp2 = sum(list_w[i + 1:])
    if ans > abs(tmp1 - tmp2):
        ans = abs(tmp1 - tmp2)
print(ans) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i list_w = [int(i) for i in input().split()] list_w [int(i) for i in input().split()] tmp1 = 0 tmp1 0 tmp2 = 0 tmp2 0 ans = sum(list_w) ans sum(list_w) sum list_w for i in range(0, len(list_w)):
    tmp1 = sum(list_w[:i + 1])
    tmp2 = sum(list_w[i + 1:])
    if ans > abs(tmp1 - tmp2):
        ans = abs(tmp1 - tmp2) i range(0, len(list_w)) range 0 len(list_w) len list_w tmp1 = sum(list_w[:i + 1]) tmp1 sum(list_w[:i + 1]) sum list_w[:i + 1] list_w :i + 1 i + 1 i 1 tmp2 = sum(list_w[i + 1:]) tmp2 sum(list_w[i + 1:]) sum list_w[i + 1:] list_w i + 1: i + 1 i 1 if ans > abs(tmp1 - tmp2):
        ans = abs(tmp1 - tmp2) ans > abs(tmp1 - tmp2) ans abs(tmp1 - tmp2) abs tmp1 - tmp2 tmp1 tmp2 ans = abs(tmp1 - tmp2) ans abs(tmp1 - tmp2) abs tmp1 - tmp2 tmp1 tmp2 print(ans) print ans tmp2 = 0 0 tmp2 ans = abs(tmp1 - tmp2) abs(tmp1 - tmp2) ans tmp1 = 0 0 tmp1 ans = sum(list_w) sum(list_w) ans tmp1 = sum(list_w[:i + 1]) sum(list_w[:i + 1]) tmp1 n = int(input()) int(input()) n tmp2 = sum(list_w[i + 1:]) sum(list_w[i + 1:]) tmp2 list_w = [int(i) for i in input().split()] [int(i) for i in input().split()] list_w
n = int(input())
list_w = [int(i) for i in input().split()]
tmp1 = 0
tmp2 = 0
ans = sum(list_w)
for i in range(0, len(list_w)):
    tmp1 = sum(list_w[:i + 1])
    tmp2 = sum(list_w[i + 1:])
    if ans > abs(tmp1 - tmp2):
        ans = abs(tmp1 - tmp2)
print(ans)