from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=[0]*(n+1)
ans=0
for i in range(n):
  s[i+1]=s[i]+a[i]
c=Counter(s)
for num in c.values():
  ans+=num*(num-1)/2
print(int(ans))