N = gets.to_i
W = gets.split.map(&:to_i)

sum = W.inject(:+)
middle = sum/2
x = 0
index = 0
W.each do |w|
    x += w
    if middle <= x then
        break
    end
    index += 1
end
puts ((sum - x) - x).abs