N = gets.chomp.to_i
W = gets.chomp.split.map(&:to_i)

ans = 100 * 100 + 1
0.upto(N - 2) { |i|
  s1 = W.select.with_index { |n, ind| ind <= i }.inject(:+)
  s2 = W.select.with_index { |n, ind| ind > i }.inject(:+)
  ans = [ans, (s1 - s2).abs].min
}

puts ans
