from itertools import accumulate
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

A=[0]+list(accumulate(a))
res=0
for v in Counter(A).values():
	res+=v*(v-1)//2
print(res)