from collections import Counter
from itertools import accumulate
n = int(input())
aa = list(map(int, input().split()))

s =[0] +  list(accumulate(aa))
# print(s)
ans=0
for x in Counter(s).values():
    ans+= x * (x-1) //2
print(ans)