N = int(eval(input()))

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

cums = [0]

for a in A:

    cums.append(cums[-1] + a)

from collections import Counter

ctr = Counter(cums)

ans = 0

for v in list(ctr.values()):

    ans += v*(v-1)//2

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

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

C = [0]

for a in A:

    C.append(C[-1] + a)

from collections import Counter

ctr = Counter(C)

ans = 0

for v in list(ctr.values()):

    ans += v*(v-1)//2

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)
from collections import Counter

ctr = Counter(cums)
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
C = [0]
for a in A:
    C.append(C[-1] + a)
from collections import Counter

ctr = Counter(C)
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
print(ans)

-cums = [0] +C = [0] -    cums.append(cums[-1] + a) +    C.append(C[-1] + a) -ctr = Counter(cums) +ctr = Counter(C)