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

ans = 10000
(N-1).times do |i|
    t = i+1
    s_1 = W[0,t].inject(:+)
    s_2 = W[t..-1].inject(:+)
    s_abs = (s_1 - s_2).abs
    if s_abs == 0 then
        ans = 0
        break
    elsif s_abs < ans then
        ans = s_abs
    end
end

p ans