from itertools import accumulate

from collections import Counter

n=int(eval(input()))

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

a=[0]+a

A=list(accumulate(a))

B=Counter(A)

ans=0

for i in B:

  ans=ans+int((B[i]*(B[i]-1)/2))

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

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

from itertools import accumulate

from collections import Counter

a=[0]+list(accumulate(a))

a=Counter(a)

ans=0

for i in a:

  ans=ans+a[i]*(a[i]-1)//2

print(ans)

from itertools import accumulate
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
a = [0] + a
A = list(accumulate(a))
B = Counter(A)
ans = 0
for i in B:
    ans = ans + int((B[i] * (B[i] - 1) / 2))
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
from itertools import accumulate
from collections import Counter

a = [0] + list(accumulate(a))
a = Counter(a)
ans = 0
for i in a:
    ans = ans + a[i] * (a[i] - 1) // 2
print(ans)

+n = int(eval(input())) +a = list(map(int, input().split())) -n = int(eval(input())) -a = list(map(int, input().split())) -a = [0] + a -A = list(accumulate(a)) -B = Counter(A) +a = [0] + list(accumulate(a)) +a = Counter(a) -for i in B: -    ans = ans + int((B[i] * (B[i] - 1) / 2)) +for i in a: +    ans = ans + a[i] * (a[i] - 1) // 2