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

min = Float::INFINITY

N.times do |i|
    if (W[0..i].sum - W[i+1..(-1)].sum).abs <= min
        min = (W[0..i].sum - W[i+1..(-1)].sum).abs
    end
end

puts min