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