from collections import Counter
n=int(input())
l=list(map(int,input().split()))
s=[l[0]]+[0]*(n-1)
for i in range(1,n):
  s[i]=s[i-1]+l[i]
S=Counter(s);ans=0
for i in S.values():
  ans+=(i*(i-1))//2
ans+=s.count(0)
print(ans)