from itertools import accumulate
from collections import defaultdict
N,*A=map(int, open(0).read().split())
S=[0]+list(accumulate(A))
X=defaultdict(int)
ans=0
for i in range(N):
    X[S[i]]+=1
    ans+=X[S[i+1]]
print(ans)