    num = gets.to_i
    inputs = gets.split(' ').map(&:to_i)
    count = 0

    (0..num-2).each do |i|
      (i..num-1).each do |j|
        count += 1 if (inputs[i..j]).sum == 0
      end
    end
    puts count