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

min = Float::INFINITY

N.times do |i|
    break if i == N - 1

    if (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs <= min
        min = (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs
    end
end

puts min

