from itertools import accumulate
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

B = [0] + list(accumulate(A))
print(sum(v * (v - 1) // 2 for v in Counter(B).values()))
