n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  if i==0:
    b.append(a[0])
  else:
    b.append(b[-1]+a[i])
#print(b)
ans = b.count(0)
c=set(b)
for i in c:
  k=b.count(i)
  if k > 1:
    ans = ans + k*(k-1)//2
print(ans)