def main(argv)
  n = gets.chomp.to_i
  w = gets.chomp.split(' ').map(&:to_i)
  
  total = w.reduce(:+)
  
  min_diff = 1e+9
  sum = 0
  n.times do |t|
    sum += w[t]
    
    min_diff = [min_diff, (total - 2 * sum).abs].min
  end
  
  puts min_diff.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end