from math import factorial as f

L = [0]

N = int(eval(input()))

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

cnt = 0

dic = {}

dic[0] = 1

for i in range(N):

    n = L[-1] + A[i]

    L.append(n)

    dic.setdefault(n, 0)

    dic[n] += 1

for key in list(dic.keys()):

    if dic[key] > 1:

        cnt += f(dic[key]) // f(2) // f(dic[key] - 2)

print((int(cnt)))
L = [0]

N = int(eval(input()))

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

cnt = 0

dic = {}

dic[0] = 1

for i in range(N):

    n = L[-1] + A[i]

    L.append(n)

    dic.setdefault(n, 0)

    dic[n] += 1

for key in list(dic.keys()):

    n = dic[key]

    if n > 1:

        cnt += n * (n - 1) // 2

print((int(cnt)))
from math import factorial as f

L = [0]
N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in list(dic.keys()):
    if dic[key] > 1:
        cnt += f(dic[key]) // f(2) // f(dic[key] - 2)
print((int(cnt)))

L = [0]
N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in list(dic.keys()):
    n = dic[key]
    if n > 1:
        cnt += n * (n - 1) // 2
print((int(cnt)))

-from math import factorial as f - -    if dic[key] > 1: -        cnt += f(dic[key]) // f(2) // f(dic[key] - 2) +    n = dic[key] +    if n > 1: +        cnt += n * (n - 1) // 2