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

Wl = [0]
for i in range(n):
    Wl.append(Wl[i]+w[i])

a = 100000

for i in range(n+1):
    a = min(abs(-Wl[i] - Wl[i] + Wl[n]), a)

print(a)
 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 Wl = [0] Wl [0] 0 for i in range(n):
    Wl.append(Wl[i]+w[i]) i range(n) range n Wl.append(Wl[i]+w[i]) Wl.append Wl append Wl[i]+w[i] Wl[i] Wl i w[i] w i a = 100000 a 100000 for i in range(n+1):
    a = min(abs(-Wl[i] - Wl[i] + Wl[n]), a) i range(n+1) range n+1 n 1 a = min(abs(-Wl[i] - Wl[i] + Wl[n]), a) a min(abs(-Wl[i] - Wl[i] + Wl[n]), a) min abs(-Wl[i] - Wl[i] + Wl[n]) abs -Wl[i] - Wl[i] + Wl[n] -Wl[i] - Wl[i] -Wl[i] Wl[i] Wl i Wl[i] Wl i Wl[n] Wl n a print(a) print a a = min(abs(-Wl[i] - Wl[i] + Wl[n]), a) min(abs(-Wl[i] - Wl[i] + Wl[n]), a) a w = list(map(int, input().split())) list(map(int, input().split())) w n = int(input()) int(input()) n a = 100000 100000 a Wl = [0] [0] Wl
n = int(input())
w = list(map(int, input().split()))

Wl = [0]
for i in range(n):
    Wl.append(Wl[i]+w[i])

a = 100000

for i in range(n+1):
    a = min(abs(-Wl[i] - Wl[i] + Wl[n]), a)

print(a)

