from collections import defaultdict
d = defaultdict(lambda:-1)
N = int(input())
A = [int(x) for x in input().split()]
cumu=[0]
d[0]+=1
for i in A:
    cumu.append(cumu[-1]+i)
    d[cumu[-1]]+=1
ans = 0
for i in d.values():
    ans+=i*max(i-1,1)
print(ans)
