n=int(eval(input()))

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

a=[0]+a

for i in range(1,n+1):

    a[i]+=a[i-1]

#print(a)

dic={}

for i in a:

    if i in dic:

        dic[i]+=1

    else:

        dic[i]=1

ans=0

for i in list(dic.values()):

    #print(i)

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

print(ans)
import itertools

n=int(eval(input()))

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

b=[0]+[i for i in itertools.accumulate(a)]

dic={}

for i in b:

    if i in dic:

        dic[i]+=1

    else:

        dic[i]=1

ans=0

for i in list(dic.values()):

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

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
a = [0] + a
for i in range(1, n + 1):
    a[i] += a[i - 1]
# print(a)
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i in list(dic.values()):
    # print(i)
    ans += i * (i - 1) // 2
print(ans)

import itertools

n = int(eval(input()))
a = list(map(int, input().split()))
b = [0] + [i for i in itertools.accumulate(a)]
dic = {}
for i in b:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
ans = 0
for i in list(dic.values()):
    ans += i * (i - 1) // 2
print(ans)

+import itertools + -a = [0] + a -for i in range(1, n + 1): -    a[i] += a[i - 1] -# print(a) +b = [0] + [i for i in itertools.accumulate(a)] -for i in a: +for i in b: -    # print(i)