from collections import Counter

import numpy as np



N = int(eval(input()))

A = np.array(input().split(), dtype = np.int64)



c = Counter(A.cumsum())

c[0] += 1

answer = sum(x*(x-1)//2 for x in list(c.values()))

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import itertools

from collections import defaultdict



N,*A = list(map(int,read().split()))



Acum = [0] + list(itertools.accumulate(A))



counter = defaultdict(int)

answer = 0

for x in Acum:

    answer += counter[x]

    counter[x] += 1



print(answer)
from collections import Counter
import numpy as np

N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
c = Counter(A.cumsum())
c[0] += 1
answer = sum(x * (x - 1) // 2 for x in list(c.values()))
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools
from collections import defaultdict

N, *A = list(map(int, read().split()))
Acum = [0] + list(itertools.accumulate(A))
counter = defaultdict(int)
answer = 0
for x in Acum:
    answer += counter[x]
    counter[x] += 1
print(answer)

-from collections import Counter -import numpy as np +import sys -N = int(eval(input())) -A = np.array(input().split(), dtype=np.int64) -c = Counter(A.cumsum()) -c[0] += 1 -answer = sum(x * (x - 1) // 2 for x in list(c.values())) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +import itertools +from collections import defaultdict + +N, *A = list(map(int, read().split())) +Acum = [0] + list(itertools.accumulate(A)) +counter = defaultdict(int) +answer = 0 +for x in Acum: +    answer += counter[x] +    counter[x] += 1