N = int(input())
A = list(map(int, input().split()))
S = [0]
for i in range(N):
	S.append(S[i] + A[i])
S.sort()
cont = 0
ans = 0
for i in range(N + 1):
	if i >= 1 and S[i] != S[i - 1]:
		cont = 0
	ans += cont
	cont += 1
print(ans)