# -*- coding: utf-8 -*-

n=int(eval(input()))

W=list(map(int,input().split()))

t=0

while sum(W[:t])<sum(W[t:]) and t<n:

  t=t+1

print((min(abs(sum(W[:t])-sum(W[t:])),abs(sum(W[:t-1])-sum(W[t-1:])))))
# -*- coding: utf-8 -*-

n=int(eval(input()))

W=list(map(int,input().split()))

for i in range(n):

    if sum(W[:i])>sum(W[i:]) or i==n-1:

        print((min(sum(W[i-1:])-sum(W[:i-1]),sum(W[:i])-sum(W[i:]))))

        break
# -*- coding: utf-8 -*-
n = int(eval(input()))
W = list(map(int, input().split()))
t = 0
while sum(W[:t]) < sum(W[t:]) and t < n:
    t = t + 1
print((min(abs(sum(W[:t]) - sum(W[t:])), abs(sum(W[: t - 1]) - sum(W[t - 1 :])))))

# -*- coding: utf-8 -*-
n = int(eval(input()))
W = list(map(int, input().split()))
for i in range(n):
    if sum(W[:i]) > sum(W[i:]) or i == n - 1:
        print((min(sum(W[i - 1 :]) - sum(W[: i - 1]), sum(W[:i]) - sum(W[i:]))))
        break

-t = 0 -while sum(W[:t]) < sum(W[t:]) and t < n: -    t = t + 1 -print((min(abs(sum(W[:t]) - sum(W[t:])), abs(sum(W[: t - 1]) - sum(W[t - 1 :]))))) +for i in range(n): +    if sum(W[:i]) > sum(W[i:]) or i == n - 1: +        print((min(sum(W[i - 1 :]) - sum(W[: i - 1]), sum(W[:i]) - sum(W[i:])))) +        break