n = gets.to_i
w = gets.chomp.split.map(&:to_i)
 
before = 0
after = w.inject(&:+)
score = after+1
 
n.times do |i|
  before += w[i]
  after -= w[i]
  tmp = (after - before).abs
  if tmp < score
    score = tmp
  else
    break
  end
end
 
print score