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

# p N
# p W 

min = 10000 # INF
0.upto(N-2).each do |i|  # N-1 is not need to be checked
  small = 0
  0.upto(i).each do |j|
    small += W[j]
  end
  large = 0
  (i+1).upto(N-1).each do |j|
    large += W[j]
  end

  diff = (small - large).abs
  if (min > diff)
    min = diff
  end
end

p min