n=int(input())
a=[int(i) for i in input().split()]
b=[0 for i in range(n+1)]
for i in range(n):
  b[i+1]=b[i]+a[i]
b.sort()
res=0
now=0
cnt=1
for i in range(n):
  if now==b[i+1]:
    cnt+=1
  else:
    res+=(cnt-1)*cnt//2
    cnt=0
    now=b[i+1]
res+=(cnt-1)*cnt//2
print(res)