n = gets.to_i

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

min = Float::INFINITY

for i in 0..n-2 do
  sumarr1 = a[0..i]
  sumarr2 = a[i+1..-1]
  sum1 = sumarr1.inject(:+)
  sum2 = sumarr2.inject(:+)
  if (sum2-sum1).abs < min
    min = (sum2 - sum1).abs
  end
end
puts min