n = input()
n = int(n)
v = input()
li = v.split(" ")
for i in range(n):
	li[i] = int(li[i])

sum_ = []
temp = 0
for i in range(n):
	temp += li[i]
	sum_.append(temp)

sum_ = sorted(sum_)
las = sum_[0]
ct = 1
total = 0

for i in range(1,n):
	if(sum_[i]==las):
		ct += 1
	else:
		if(las==0):
			total += ct + ((ct*(ct-1))/2)
		else:
			total += ((ct*(ct-1))/2)

		ct = 1
		las = sum_[i]

total += ((ct*(ct-1))/2)

if(n==1  and sum_[0]==0):
	print(1)
else:
	print(int(total))