from itertools import accumulate
from collections import Counter

n=int(input())
a=[0]+list(map(int,input().split()))
a=list(accumulate(a))
c=Counter(a)
ans=0
for i in c.values():
    ans+=i*(i-1)//2
print(ans)