n=int(input())
s=list(map(int,input().split()))
from itertools import accumulate
from collections import Counter
p=0
t=[0]+list(accumulate(s))
for i in Counter(t).values():
    if i>1:
        p+=i*(i-1)//2
print(p)