from collections import Counter
from itertools import combinations
n = int(input())
a = list(map(int,input().split()))
A = [0]
for i in a:
    A.append(A[-1]+i)
ans = 0
B = Counter(A)
for i in B.values():
    if i >= 2:
        ans += len(tuple(combinations(range(i),r=i)))
print(ans)