import itertools
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += len(list(itertools.combinations(range(dic[key]), 2)))
print(int(cnt))