from collections import Counter
from itertools import combinations
from functools import lru_cache
@lru_cache(maxsize=None)

def kaijou(n):
    if n <= 1:
        return 1
    return kaijou(n-1)*n

def comb(n,m):
    return int(kaijou(n)/kaijou(m)/kaijou(n-m))

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 += comb(i,2)
print(ans)