n = gets.chomp.to_i
array = gets.split(" ").map(&:to_i)
difference = []
i = 0

while i <= n - 1 do
    difference << ((array[0..i]).sum - (array[(i+1)..(n-1)]).sum).abs
    i += 1
end

p difference.min
