n = gets.to_i
ary = gets.chomp.split.map(&:to_i)
ans = []
(1..n).each do |i|
  t = i
  low = 0
  high = 0
  low = ary[0..i-1]
  high = ary[i..-1]
  ans << (low.inject(:+).to_i - high.inject(:+).to_i).abs
end
puts ans.min