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

arr = []
arr.push(0)

for i in 1..input do
	arr.push(arr.last+nums[i-1])
end

arr.sort!
p arr
pointer = 0
ans = 0
while pointer <= input do
	num = arr[pointer]
	i = pointer+1
	count = 1
	while arr[i] == num do
		count += 1
		i += 1
	end
	
	if count > 1 then 
		count = count*(count-1)/2
		ans +=count
	end
	
	pointer = i

end
puts ans
