from itertools import accumulate
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
s = Counter([0] + list(accumulate(a)))

cnt = 0
for v in s.values():
    cnt += v*(v-1)//2
print(cnt)