import math
def aPb(a,b):return(math.factorial(a)//math.factorial(a-b))
def aCb(a,b):return(aPb(a,b)//math.factorial(b))
def ex(X):
  b=X[:]
  b.append("null")
  a=[]
  for i in range(len(X)):
    if b[i]!=b[i+1]:a.append(b[i])
  return a
n,a=int(input()),list(map(int,input().split()));b=[0]
for i in a:b.append(b[-1]+i)
b.sort();d=ex(b)
c=0;ans=0
for i in d:ans+=aCb(b.count(i),2)
print(ans)