from collections import Counter

n = int(eval(input()))

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

cum = [0] * (n + 1)

for i in range(n):

    cum[i + 1] = cum[i] + a[i]

cum = sorted(cum)

count = Counter(cum)

ans = 0

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

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

print(ans)
from collections import Counter

N = int(eval(input()))

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

cum = [0]

for a in A:

    cum.append(cum[-1] + a)

count = Counter(cum)

ans = 0

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

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

print(ans)
from collections import Counter

n = int(eval(input()))
a = [int(i) for i in input().split()]
cum = [0] * (n + 1)
for i in range(n):
    cum[i + 1] = cum[i] + a[i]
cum = sorted(cum)
count = Counter(cum)
ans = 0
for v in list(count.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter

N = int(eval(input()))
A = [int(i) for i in input().split()]
cum = [0]
for a in A:
    cum.append(cum[-1] + a)
count = Counter(cum)
ans = 0
for v in list(count.values()):
    ans += v * (v - 1) // 2
print(ans)

-n = int(eval(input())) -a = [int(i) for i in input().split()] -cum = [0] * (n + 1) -for i in range(n): -    cum[i + 1] = cum[i] + a[i] -cum = sorted(cum) +N = int(eval(input())) +A = [int(i) for i in input().split()] +cum = [0] +for a in A: +    cum.append(cum[-1] + a)