from itertools import accumulate
from collections import Counter
n = int(input())
nums = list(map(int,input().split()))
s = [0]+list(accumulate(nums))
ans = 0
for i in Counter(S).values():
    if i > 1:
        ans += i * (i - 1) // 2
print(ans)