import collections
from itertools import accumulate
from scipy.special import comb

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

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += comb(v,2,exact=True)
print(cnt)