num = gets.to_i
array = gets.split(" ").map(&:to_i)
sum = 0
count = 0
num.times do |i|
    sum = 0
  (num-i).times do |j|  
    sum += array[i+j]
    if sum == 0
      count += 1
    end
  end
end
puts count
