# your code goes here
N = int(input())
A = list(map(int,input().split()))

S = [0]
for i in range(N):
	S.append(S[i]+ A[i])
# S = list(map(abs,S))
T = list(set(S))
ans = 0

for i in T:
	num = S.count(i)
	ans += num*(num-1)//2
print(ans)