from collections import Counter
n=int(input())
a = [int(i) for i in input().split()]
b=[0]
s=0
for i in a:
  s+=i
  b.append(s)
c= Counter(b)
ans=0
for i in c:
  ans+=int(c[i]*(c[i]-1)/2)
print(ans)
#copy code