N = int(eval(input()))

A = [int(i) for i in input().split()]

ca = [A[0]] + [0]*(N-1)



for i in range(1,N):

    ca[i] = ca[i-1] + A[i]



count = 1

number = 0

number += ca.count(0)

sca = sorted(ca) + ['hoge']

for i in range(1,N+1):

    if sca[i] == sca[i-1]:

        count += 1

    else:

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

        count = 1





print((int(number)))
N = int(eval(input()))

A = [int(i) for i in input().split()]



dic = {}

S = 0

dic[0] = 1



for i in range(N):

    S += A[i]

    if S in dic:

        dic[S] += 1

    else:

        dic[S] = 1



number = 0



for i in dic:

    N = dic[i]

    number += N * (N - 1) / 2



print((int(number)))

N = int(eval(input()))
A = [int(i) for i in input().split()]
ca = [A[0]] + [0] * (N - 1)
for i in range(1, N):
    ca[i] = ca[i - 1] + A[i]
count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ["hoge"]
for i in range(1, N + 1):
    if sca[i] == sca[i - 1]:
        count += 1
    else:
        number += count * (count - 1) / 2
        count = 1
print((int(number)))

N = int(eval(input()))
A = [int(i) for i in input().split()]
dic = {}
S = 0
dic[0] = 1
for i in range(N):
    S += A[i]
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
number = 0
for i in dic:
    N = dic[i]
    number += N * (N - 1) / 2
print((int(number)))

-ca = [A[0]] + [0] * (N - 1) -for i in range(1, N): -    ca[i] = ca[i - 1] + A[i] -count = 1 +dic = {} +S = 0 +dic[0] = 1 +for i in range(N): +    S += A[i] +    if S in dic: +        dic[S] += 1 +    else: +        dic[S] = 1 -number += ca.count(0) -sca = sorted(ca) + ["hoge"] -for i in range(1, N + 1): -    if sca[i] == sca[i - 1]: -        count += 1 -    else: -        number += count * (count - 1) / 2 -        count = 1 +for i in dic: +    N = dic[i] +    number += N * (N - 1) / 2