from itertools import accumulate
from collections import Counter
from scipy.special import comb
n = int(input())
a = map(int,input().split())
al = list(accumulate(a))
cal = Counter(al)
ans = 0
for k,v in cal.items():
    if k == 0:
        ans += comb(v + 1,2)
    else:
        ans += comb(v,2)
print(int(ans))