N=int(eval(input()))

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

for i in range(N):

    num[i+1]=num[i]+num[i+1]

num=sorted(num)+[-1]

count,n=0,0

flag=num[0]

for i in num:

    if i==flag:

        n +=1

    else:

        count +=(n*(n-1))//2

        flag=i

        n=1

print(count)
from collections import Counter

n=int(eval(input()))

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

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

    A[i] +=A[i-1]



ans=0

for m in list(Counter(A).values()):

    if m==1:continue

    else:

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



print(ans)
N = int(eval(input()))
num = [0] + list(map(int, input().split()))
for i in range(N):
    num[i + 1] = num[i] + num[i + 1]
num = sorted(num) + [-1]
count, n = 0, 0
flag = num[0]
for i in num:
    if i == flag:
        n += 1
    else:
        count += (n * (n - 1)) // 2
        flag = i
        n = 1
print(count)

from collections import Counter

n = int(eval(input()))
A = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    A[i] += A[i - 1]
ans = 0
for m in list(Counter(A).values()):
    if m == 1:
        continue
    else:
        ans += (m * (m - 1)) // 2
print(ans)

-N = int(eval(input())) -num = [0] + list(map(int, input().split())) -for i in range(N): -    num[i + 1] = num[i] + num[i + 1] -num = sorted(num) + [-1] -count, n = 0, 0 -flag = num[0] -for i in num: -    if i == flag: -        n += 1 +from collections import Counter + +n = int(eval(input())) +A = [0] + list(map(int, input().split())) +for i in range(1, n + 1): +    A[i] += A[i - 1] +ans = 0 +for m in list(Counter(A).values()): +    if m == 1: +        continue -        count += (n * (n - 1)) // 2 -        flag = i -        n = 1 -print(count) +        ans += (m * (m - 1)) // 2 +print(ans)