n= int(input())
a=[int(i) for i in input().split()]
b=[0]
k=0
for i in a:
  k+=i
  b.append(k)
c={}
for i in b:
  if i in c:
    c[i]+=1
  else:
    c[i]=1
k=0
for i in c:
  k+=c[i]*(c[i]-1)//2
print(k)