n=int(eval(input()))

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

from itertools import accumulate

from collections import Counter

from math import factorial

p=0

def f(n,m):

    return factorial(n)//(factorial(n-m)*factorial(m))

t=[0]+list(accumulate(s))

for i in list(Counter(t).values()):

    if i>1:

        p+=f(i,2)

print(p)
n=int(eval(input()))

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

from itertools import accumulate

from collections import Counter

p=0

t=[0]+list(accumulate(s))

for i in list(Counter(t).values()):

    if i>1:

        p+=i*(i-1)//2

print(p)
n = int(eval(input()))
s = list(map(int, input().split()))
from itertools import accumulate
from collections import Counter
from math import factorial

p = 0


def f(n, m):
    return factorial(n) // (factorial(n - m) * factorial(m))


t = [0] + list(accumulate(s))
for i in list(Counter(t).values()):
    if i > 1:
        p += f(i, 2)
print(p)

n = int(eval(input()))
s = list(map(int, input().split()))
from itertools import accumulate
from collections import Counter

p = 0
t = [0] + list(accumulate(s))
for i in list(Counter(t).values()):
    if i > 1:
        p += i * (i - 1) // 2
print(p)

-from math import factorial - - -def f(n, m): -    return factorial(n) // (factorial(n - m) * factorial(m)) - - -        p += f(i, 2) +        p += i * (i - 1) // 2