def balance
	n = gets.chomp.to_i
	w = gets.chomp.split(/\s/).map{|x| x.to_i}

	p n
	p w

	min = 100*100

	left = w[0]
	right = w[1..-1]
	#r = right.sum # for RUby 2.4
	r = right.inject(0){|sum,x| sum + x }

	for i in 1..n-1 do
		min = [min, (left-r).abs].min
		#p min
		item = right.shift
		left += item
		r -= item
	end

	p min
end

balance