import collections
n=int(input())
A=list(map(int,input().split()))
B=[0]
for i in range(n):
  B.append(B[-1]+A[i])
C=collections.Counter(B)
C=list(C.values())
ans=0
for i in range(len(C)):
  ans=ans+C[i]*(C[i]-1)//2
print(ans)