n = gets.chomp.to_i
ary = gets.chomp.split(" ").map(&:to_i)

res  = []
size = ary.size - 1

ary.each_with_index do |v, k|
  if k == size
    break
  end
  t = ary.slice(0..k).inject(:+)
  t2 = ary.slice(k+1..size).inject(:+)

  if t > t2
    res << t - t2
  else
    res << t2 - t
  end
end
puts res.min

