require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

cumlative_sums = A.dup

result = 0

N.times do |i|
  new_arr = []
  cumlative_sums.each.with_index do |num, j|
    target_index = i + j + 1
    break if target_index >= A.length

    sum = num + A[target_index]
    result += 1 if sum == 0
    new_arr.push(sum)
  end
  cumlative_sums = new_arr
end

puts result
