N=int(input())
A = list(map(int,input().split()))
B=[0]*(N-1)
total=0
count=0

for i in range(N-1):
  total+=A[i]
  B[i]=total
  
total=0
B.sort()
B.append(10000000000)
for i in range(N-1):
  count+=1
  if B[i]!=B[i+1]:
    if count>=2:
        total+=count*(count+1)//2
    count=0
#print(B)
print(total)