from itertools import accumulate
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=list(accumulate(A))
A=[0]+A
B=Counter(A)
ans=0
for i in B:
  ans=int(ans+B[i]*(B[i]-1)/2)
print(ans)