def cal_combi(num)
  (num * (num-1)) / 2
end

n = gets.chomp.to_i
nums = gets.chomp.split(' ').map(&:to_i)

# 累積和
a = [0]
1.upto(n) do |i|
  a << nums[i-1] + a[i-1]
end

count = 0
a.uniq.each do |num|
  combi = a.count(num)
  count += cal_combi(combi)
end

puts count