N=int(eval(input()))

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

cumulative_sum=0

count=0

counter={0:1}

for a in A:

    cumulative_sum+=a

    if cumulative_sum not in counter:

        counter[cumulative_sum]=0

    count+=counter[cumulative_sum]

    counter[cumulative_sum]+=1

print(count)
import itertools

import collections

N=int(eval(input()))

A=list(itertools.accumulate(list(map(int,input().split()))))

count=0

for s in list(collections.Counter(A+[0]).values()):

    count+=s*(s-1)//2

print(count)
N = int(eval(input()))
A = list(map(int, input().split()))
cumulative_sum = 0
count = 0
counter = {0: 1}
for a in A:
    cumulative_sum += a
    if cumulative_sum not in counter:
        counter[cumulative_sum] = 0
    count += counter[cumulative_sum]
    counter[cumulative_sum] += 1
print(count)

import itertools
import collections

N = int(eval(input()))
A = list(itertools.accumulate(list(map(int, input().split()))))
count = 0
for s in list(collections.Counter(A + [0]).values()):
    count += s * (s - 1) // 2
print(count)

+import itertools +import collections + -A = list(map(int, input().split())) -cumulative_sum = 0 +A = list(itertools.accumulate(list(map(int, input().split())))) -counter = {0: 1} -for a in A: -    cumulative_sum += a -    if cumulative_sum not in counter: -        counter[cumulative_sum] = 0 -    count += counter[cumulative_sum] -    counter[cumulative_sum] += 1 +for s in list(collections.Counter(A + [0]).values()): +    count += s * (s - 1) // 2