import collections
import itertools

n = int(input())
a = list(map(int, input().split(" ")))

s = [0]
for i in range(1, n + 1):
    s.append(s[i-1] + a[i-1] )

print(sum([len(list(itertools.combinations(list(range(i)), 2))) for i in collections.Counter(s).values()]))
