N = int(eval(input()))

l = [int(x) for x in input().split()]

s = [0] * (N+1)

for i in range(N):

    s[i+1] = s[i] + l[i]

s.sort()



#count

table= {}

for i in range(N+1):

    if s[i] in table:

        table[s[i]] += 1

    else:

        table[s[i]] = 1

ans = 0

for key,val in list(table.items()):

    if val >= 2:

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

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

l = [int(x) for x in input().split()]

s = [0] * (N+1)

for i in range(N):

    s[i+1] = s[i] + l[i]

#count

table= {}

for i in range(N+1):

    if s[i] in table:

        table[s[i]] += 1

    else:

        table[s[i]] = 1

ans = 0

for key,val in list(table.items()):

    if val >= 2:

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

print(ans)
N = int(eval(input()))
l = [int(x) for x in input().split()]
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + l[i]
s.sort()
# count
table = {}
for i in range(N + 1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1
ans = 0
for key, val in list(table.items()):
    if val >= 2:
        ans += val * (val - 1) // 2
print(ans)

N = int(eval(input()))
l = [int(x) for x in input().split()]
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + l[i]
# count
table = {}
for i in range(N + 1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1
ans = 0
for key, val in list(table.items()):
    if val >= 2:
        ans += val * (val - 1) // 2
print(ans)

-s.sort()