n = gets.chomp.to_i
ws = gets.chomp.split(' ').map(&:to_i)

ans = 100
(0...n-1).each do |i|
    w1 = ws[(0..i)].reduce(:+)
    w2 = ws[(i+1..n-1)].reduce(:+)
    amt = (w1 - w2).abs
    ans = amt if amt < ans
end

puts ans
