from itertools import accumulate
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
b = [0] + list(accumulate(a))
print(sum(v * (v - 1) // 2 for v in Counter(b).values()))
