from collections import Counter

import numpy as np



N = int(eval(input()))

A = np.array(input().split(), dtype = np.int64)



c = Counter(A.cumsum())

c[0] += 1

answer = sum(x*(x-1)//2 for x in list(c.values()))

print(answer)

N = int(eval(input()))

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

csum = [0]

temp = 0

for a in A:

    temp += a

    csum.append(temp)

# csum.sort()

# print(csum)

from collections import Counter

freq = Counter(csum)

ans = 0

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

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

print(ans)
from collections import Counter
import numpy as np

N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
c = Counter(A.cumsum())
c[0] += 1
answer = sum(x * (x - 1) // 2 for x in list(c.values()))
print(answer)

N = int(eval(input()))
A = list(map(int, input().split()))
csum = [0]
temp = 0
for a in A:
    temp += a
    csum.append(temp)
# csum.sort()
# print(csum)
from collections import Counter

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

+N = int(eval(input())) +A = list(map(int, input().split())) +csum = [0] +temp = 0 +for a in A: +    temp += a +    csum.append(temp) +# csum.sort() +# print(csum) -import numpy as np -N = int(eval(input())) -A = np.array(input().split(), dtype=np.int64) -c = Counter(A.cumsum()) -c[0] += 1 -answer = sum(x * (x - 1) // 2 for x in list(c.values())) -print(answer) +freq = Counter(csum) +ans = 0 +for v in list(freq.values()): +    ans += (v * (v - 1)) // 2 +print(ans)