from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
b=[0]
for i in a:b.append(b[-1]+i)
d=defaultdict(int)
for i in b:d[i]+=1
ans=0
for i in set(b):ans+=d[i]*(d[i]-1)//2
print(ans)