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