gets
array = gets.split(" ").map(&:to_i)
sum = 0
array.length.times do |i|
  array.length.times do |j|
    if array[j..j+i+1].inject{|k,l|l+= k} == 0 && j+i+1 < array.length
      sum += 1
    end
  end
end
puts sum += array.count(0)