import collections

N = int(input())
A = list(map(int, input().split()))

S = [0]

def comb(n,r):
    if n < 0 or r < 0 or n < r: 
        return 0
    elif n == 0 or r == 0: 
        return 1
    return comb(n-1,r-1)+comb(n-1,r)

for i in A:
    S.append(S[-1] + i)

count = 0
count_dict = collections.Counter(S)
for i in count_dict.values():
    count += comb(i,2)
print(count)