N = int(input())
Ai = list(map(int,input().split()))
    
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

def iCj(i, j):
  mot = 1
  chi = 1
  for x in range(j):
    chi *= i-x
    mot *= x+1
  comb = int(chi/mot)
  return comb


base = create_list()
count = 0
base.sort()
i = 0
while(i<N+1):
  this = base.count(base[i])
  if(this >= 2):
    count += iCj(this,2)
  i += this
print(count)