import itertools

import collections

N = int(eval(input()))

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

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

acount = collections.Counter(acum)

print((sum(n * (n-1) // 2 for n in list(acount.values()))))
from itertools import *

from collections import *

eval(input())

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

print((sum(n*(n-1)//2 for n in list(Counter(A+[0]).values()))))
import itertools
import collections

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

from itertools import *
from collections import *

eval(input())
A = list(accumulate(list(map(int, input().split()))))
print((sum(n * (n - 1) // 2 for n in list(Counter(A + [0]).values()))))

-import itertools -import collections +from itertools import * +from collections import * -N = int(eval(input())) -A = list(map(int, input().split())) -acum = [0] + list(itertools.accumulate(A)) -acount = collections.Counter(acum) -print((sum(n * (n - 1) // 2 for n in list(acount.values())))) +eval(input()) +A = list(accumulate(list(map(int, input().split())))) +print((sum(n * (n - 1) // 2 for n in list(Counter(A + [0]).values()))))