n = gets.to_i
L_arr = gets.split.map(&:to_i)
abs_arr = []


(1..(n-1)).to_a.each do |i|
  (L_arr.slice(0,i).sum - L_arr.slice(i,n).sum).abs
  abs_arr <<  (L_arr.slice(0,i).sum - L_arr.slice(i,n).sum).abs
end

abs_arr.sort!
p abs_arr[0]
