from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in range(1,n+1):
  b[i]=b[i-1]+a[i-1]
l=list(Counter(b).values())
for i in range(len(l)):
  x=l[i]
  l[i]=(x**2-x)//2
print(sum(l))