N = gets.chomp.to_i
ws = gets.chomp.split(' ').map(&:to_i)
min = ws.inject(:+)

(N-1).times do |i|
    if (ws.slice((i+1)..(N-1)).inject(:+) - ws.slice(0..i).inject(:+) ).abs < min
        min = (ws.slice((i+1)..(N-1)).inject(:+) - ws.slice(0..i).inject(:+)).abs
    end
end
p min