n = int(input())
w = list(map(int, input().split()))
diff_min = sum(w)
for i in range(len(w)):
    s1 = sum(w[:i + 1])
    s2 = sum(w[i + 1:])
    diff = abs(s1 - s2)
    if diff < diff_min:
        diff_min = diff
print(diff_min) 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 diff_min = sum(w) diff_min sum(w) sum w for i in range(len(w)):
    s1 = sum(w[:i + 1])
    s2 = sum(w[i + 1:])
    diff = abs(s1 - s2)
    if diff < diff_min:
        diff_min = diff i range(len(w)) range len(w) len w s1 = sum(w[:i + 1]) s1 sum(w[:i + 1]) sum w[:i + 1] w :i + 1 i + 1 i 1 s2 = sum(w[i + 1:]) s2 sum(w[i + 1:]) sum w[i + 1:] w i + 1: i + 1 i 1 diff = abs(s1 - s2) diff abs(s1 - s2) abs s1 - s2 s1 s2 if diff < diff_min:
        diff_min = diff diff < diff_min diff diff_min diff_min = diff diff_min diff print(diff_min) print diff_min s1 = sum(w[:i + 1]) sum(w[:i + 1]) s1 diff_min = sum(w) sum(w) diff_min diff = abs(s1 - s2) abs(s1 - s2) diff w = list(map(int, input().split())) list(map(int, input().split())) w diff_min = diff diff diff_min s2 = sum(w[i + 1:]) sum(w[i + 1:]) s2 n = int(input()) int(input()) n
n = int(input())
w = list(map(int, input().split()))
diff_min = sum(w)
for i in range(len(w)):
    s1 = sum(w[:i + 1])
    s2 = sum(w[i + 1:])
    diff = abs(s1 - s2)
    if diff < diff_min:
        diff_min = diff
print(diff_min)