n = int(eval(input()))

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

S = [0]*(n+1)

num={}

for i in range(n):

    S[i+1] = S[i] + A[i]

for i in S:

    if str(i) in list(num.keys()):

        num[str(i)] += 1

    else:

        num[str(i)] = 1

out = [i*(i-1)//2 for i in list(num.values()) if i>1]

print((sum(out)))
n = int(eval(input()))

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

S = [0]*(n+1)

num = {}

for i in range(n):

    S[i+1] = S[i] + A[i]

for i in S:

    s = str(i)

    num[s] = 1 if s not in list(num.keys()) else num[s]+1

out = [i*(i-1)//2 for i in list(num.values()) if i > 1]

print((sum(out)))
n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
num = {}
for i in range(n):
    S[i + 1] = S[i] + A[i]
for i in S:
    if str(i) in list(num.keys()):
        num[str(i)] += 1
    else:
        num[str(i)] = 1
out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1]
print((sum(out)))

n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
num = {}
for i in range(n):
    S[i + 1] = S[i] + A[i]
for i in S:
    s = str(i)
    num[s] = 1 if s not in list(num.keys()) else num[s] + 1
out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1]
print((sum(out)))

-    if str(i) in list(num.keys()): -        num[str(i)] += 1 -    else: -        num[str(i)] = 1 +    s = str(i) +    num[s] = 1 if s not in list(num.keys()) else num[s] + 1