n=int(input())
A=[int(i) for i in input().split()]
S=[0]
s=0
for i in range(n):
  s+=A[i]
  S.append(s)
import collections
c=collections.Counter(S)
ans=0
for a in set(S):
  k=c[a]
  ans+=k*(k-1)//2
print(ans)