n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

b = []
sum = 0
a.each do |a_v|
  sum += a_v
  b << sum
end

zero_count = a.select{ |e| e == 0}.count
count = b.select{ |e| e == 0 }.count - zero_count
while b.length > 1
  b_v = b.shift
  count += b.map{ |e| e - b_v }.select{ |e| e == 0 }.count
end
puts count
