n=int(eval(input()))

a=[0]+list(map(int,input().split()))

from itertools import accumulate

a=accumulate(a)

a=list(a)

a.sort()

from collections import Counter

c=Counter(a)

ans=0

for k,v in list(c.items()):

    if v>=2:

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

print(ans)

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

a = [0] + list(map(int, input().split()))

from collections import Counter

from itertools import accumulate

s = list(accumulate(a))

c = Counter(s)

ans = 0

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

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

print(ans)







n = int(eval(input()))
a = [0] + list(map(int, input().split()))
from itertools import accumulate

a = accumulate(a)
a = list(a)
a.sort()
from collections import Counter

c = Counter(a)
ans = 0
for k, v in list(c.items()):
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

N = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
from collections import Counter
from itertools import accumulate

s = list(accumulate(a))
c = Counter(s)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

-n = int(eval(input())) +N = list(map(int, input().split())) +from collections import Counter -a = accumulate(a) -a = list(a) -a.sort() -from collections import Counter - -c = Counter(a) +s = list(accumulate(a)) +c = Counter(s) -for k, v in list(c.items()): -    if v >= 2: -        ans += v * (v - 1) // 2 +for v in list(c.values()): +    ans += v * (v - 1) // 2