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

    t = 0
    (0..num-1).each do |i|
      t += inputs[i]
      memo << t
      count += 1 if t == 0
    end

    if num >= 2
      (1..num-1).each do |i|
        (i..num-1).map do |j|
          t = memo[j] - memo[i-1]
          count += 1 if t == 0
        end
      end
    end
    puts count