n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
hash = Hash.new(0)
sum = 0
ans = 0
a.each do |v|
  sum += a
  ans += 1 if sum == 0
  ans += hash[sum] if hash[sum] > 0
  hash[sum] += 1
end
puts ans
