N = int(eval(input()))

W = [int(x) for x in input().split()]



dif = []

for T in range(N):

    S1 = sum(W[:T])

    S2 = sum(W[T:])

    dif.append(abs(S1-S2))



print((min(dif)))
import itertools



N = int(eval(input()))

W = [int(x) for x in input().split()]



accum_W = list(itertools.accumulate(W))

sm = accum_W[-1]



ans = min(abs(sm - 2*x) for x in accum_W)

print(ans)
N = int(eval(input()))
W = [int(x) for x in input().split()]
dif = []
for T in range(N):
    S1 = sum(W[:T])
    S2 = sum(W[T:])
    dif.append(abs(S1 - S2))
print((min(dif)))

import itertools

N = int(eval(input()))
W = [int(x) for x in input().split()]
accum_W = list(itertools.accumulate(W))
sm = accum_W[-1]
ans = min(abs(sm - 2 * x) for x in accum_W)
print(ans)

+import itertools + -dif = [] -for T in range(N): -    S1 = sum(W[:T]) -    S2 = sum(W[T:]) -    dif.append(abs(S1 - S2)) -print((min(dif))) +accum_W = list(itertools.accumulate(W)) +sm = accum_W[-1] +ans = min(abs(sm - 2 * x) for x in accum_W) +print(ans)