n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
ac=list(accumulate(a))
ac.insert(0,0)

d={}
for i in ac:
    d[i]=d.get(i,0)+1

ans=0
for i in d.values():
    if i>=2:
        ans+=i*(i-1)//2
print(ans)