from itertools import accumulate
from collections import Counter
N = int(input())
Alist = [0]+list(map(int, input().split()))
cumsum = Counter(sorted(list(accumulate(Alist)))).most_common()
ans = 0

for k, v in cumsum:
    if v > 1:
        ans += n*(n-1)//2
    else:
        break
print(ans)
