from collections import Counter
N=int(input())
A=list(map(int,input().split()))
As=[0]*(N+1)
for i in range(N):
  As[i+1]=A[i]+As[i]
v=Counter(As).values()
ans=0
for i in v:
  ans+=i*(i-1)//2
print(ans)