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

s1_list = Array.new
sum = ls.inject(:+)
for i in 1..n-1
  s1 = 0
  for j in 0..i
    s1 += ls[j]

  end
    s2 = sum - s1
    s1_list << (s1 - s2).abs

end

p s1_list.min