from itertools import accumulate
from collections import Counter

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

acc = accumulate(a)
c = Counter(acc)
ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)
