# A - Zero-Sum Ranges

from itertools import accumulate

from collections import defaultdict as dd

n=int(eval(input()))

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

acc=accumulate(a)

acc=list(acc)

acc.sort()



# print(acc)

d=dd(int)

for aa in acc:

    d[aa]+=1



ans=0

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

    if v>=2:

        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)

# A - Zero-Sum Ranges
from itertools import accumulate
from collections import defaultdict as dd

n = int(eval(input()))
a = [0] + list(map(int, input().split()))
acc = accumulate(a)
acc = list(acc)
acc.sort()
# print(acc)
d = dd(int)
for aa in acc:
    d[aa] += 1
ans = 0
for k, v in list(d.items()):
    if v >= 2:
        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)

-# A - Zero-Sum Ranges -from itertools import accumulate -from collections import defaultdict as dd - -acc = accumulate(a) -acc = list(acc) -acc.sort() -# print(acc) -d = dd(int) -for aa in acc: -    d[aa] += 1 +from itertools import accumulate + +a = accumulate(a) +a = list(a) +a.sort() +from collections import Counter + +c = Counter(a) -for k, v in list(d.items()): +for k, v in list(c.items()):