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

l = 0
r = w.inject(:+)
min = r - l
n.times do |i|
  l += w[i]
  r -= w[i]
  c = (r - l).abs
  if min > c then
    min = c
  elsif min < c then
    break
  end
end

puts min