INF=Float::INFINITY
n = gets.chomp.to_i
w = gets.chomp.split.map(&:to_i)

ans = INF
1.upto(n-1).each do |t|
  can = (w.slice(0,t).inject(:+) - w.slice(t, 1000).inject(:+)).abs
  ans = can if ans > can
end

puts ans

