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

min = 10*100
strs.each_with_index do |str, idx|
  break if idx == n-1
  diff = (strs[0..idx].inject(:+) - strs[(idx+1)..-1].inject(:+)).abs
  min = diff if diff < min
end
puts min