gets

weights = gets.split.map(&:to_i)

min = 9999999999
(weights.size - 1).times do |i|
  s1 = weights[0..i].inject(&:+)
  s2 = weights[i+1..-1].inject(&:+)
  if (s1 - s2).abs < min
    min = (s1 - s2).abs
  end
end

puts min