# a 200

from collections import Counter

from math import factorial



N = int(eval(input()))

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



#累計和

wa = [0]

for ai in a:

    wa.append(wa[-1]+ai)

wa = wa[1:]



def combination(n, r):

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



c = Counter(wa)

ans = 0



for k,v in list(c.items()):

    if v<2: continue

    ans += combination(v, 2)

    

ans += c[0]

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

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

s = [0]

d = {0:1}

for i in range(N):

    nex = s[-1]+a[i]

    s.append(nex)

    if nex not in d:

        d[nex] = 0

    d[nex] += 1

    

ans = 0

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

    if v >= 2:

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

print(ans)

# a 200
from collections import Counter
from math import factorial

N = int(eval(input()))
a = list(map(int, input().split()))
# 累計和
wa = [0]
for ai in a:
    wa.append(wa[-1] + ai)
wa = wa[1:]


def combination(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r))


c = Counter(wa)
ans = 0
for k, v in list(c.items()):
    if v < 2:
        continue
    ans += combination(v, 2)
ans += c[0]
print(ans)

N = int(eval(input()))
a = list(map(int, input().split()))
s = [0]
d = {0: 1}
for i in range(N):
    nex = s[-1] + a[i]
    s.append(nex)
    if nex not in d:
        d[nex] = 0
    d[nex] += 1
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += int(v * (v - 1) / 2)
print(ans)

-# a 200 -from collections import Counter -from math import factorial - -# 累計和 -wa = [0] -for ai in a: -    wa.append(wa[-1] + ai) -wa = wa[1:] - - -def combination(n, r): -    return factorial(n) // (factorial(r) * factorial(n - r)) - - -c = Counter(wa) +s = [0] +d = {0: 1} +for i in range(N): +    nex = s[-1] + a[i] +    s.append(nex) +    if nex not in d: +        d[nex] = 0 +    d[nex] += 1 -for k, v in list(c.items()): -    if v < 2: -        continue -    ans += combination(v, 2) -ans += c[0] +for v in list(d.values()): +    if v >= 2: +        ans += int(v * (v - 1) / 2)