N=input()
A=[int(x)for x in input().split()]
B=[0]
C=[]
for x in A:
  i=B[-1]+x
  B.append(i)
  if i not in C:
    C.append(i)

count=0

for x in C:
  i=B.count(x)
  if i>1:
    count+=(i-1)*i//2
print(count)