N = int(input())
A = [int(i) for i in input().split()]
i = 1
while i < N:
	A[i] += A[i - 1]
	i += 1
a = {}
for i in A:
	if i in a:
		a[i] += 1
	else:
		a[i] = 1
ans = A.count(0)
for i in a.values():
	ans += (i - 1) * i // 2
print(ans)