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

left = 0
right = w.reduce(&:+)

ans = right
n.times do |i|
  left += w[i]
  right -= w[i]
  diff = (left - right).abs
  ans = diff if ans > diff
end

puts(ans)