from math import factorial

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

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



tmp=[0]

sum=0

for i in range(len(A)):

    sum+=A[i]

    tmp.append(sum)



tmp.sort()

tmp.append(1.2)



def combinations_count(n, r):

    return factorial(n) // (factorial(n - r) * factorial(r))



cnt=1

ans=0

for i in  range(0,len(tmp)-1):

    if tmp[i]==tmp[i+1]:

        cnt+=1

    elif tmp[i]!=tmp[i+1]:

        if cnt>1:

            ans+=combinations_count(cnt,2)

        cnt=1



print(ans)
from collections import defaultdict

n=int(eval(input()))

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

ans=0



d=defaultdict(int)

sum_a=0

d[sum_a]+=1

for i in range(n):

    sum_a+=a[i]

    ans+=d[sum_a]

    d[sum_a]+=1

print(ans)
from math import factorial

N = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp = [0]
sum = 0
for i in range(len(A)):
    sum += A[i]
    tmp.append(sum)
tmp.sort()
tmp.append(1.2)


def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


cnt = 1
ans = 0
for i in range(0, len(tmp) - 1):
    if tmp[i] == tmp[i + 1]:
        cnt += 1
    elif tmp[i] != tmp[i + 1]:
        if cnt > 1:
            ans += combinations_count(cnt, 2)
        cnt = 1
print(ans)

from collections import defaultdict

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
d = defaultdict(int)
sum_a = 0
d[sum_a] += 1
for i in range(n):
    sum_a += a[i]
    ans += d[sum_a]
    d[sum_a] += 1
print(ans)

-from math import factorial +from collections import defaultdict -N = list(map(int, input().split())) -A = list(map(int, input().split())) -tmp = [0] -sum = 0 -for i in range(len(A)): -    sum += A[i] -    tmp.append(sum) -tmp.sort() -tmp.append(1.2) - - -def combinations_count(n, r): -    return factorial(n) // (factorial(n - r) * factorial(r)) - - -cnt = 1 +n = int(eval(input())) +a = list(map(int, input().split())) -for i in range(0, len(tmp) - 1): -    if tmp[i] == tmp[i + 1]: -        cnt += 1 -    elif tmp[i] != tmp[i + 1]: -        if cnt > 1: -            ans += combinations_count(cnt, 2) -        cnt = 1 +d = defaultdict(int) +sum_a = 0 +d[sum_a] += 1 +for i in range(n): +    sum_a += a[i] +    ans += d[sum_a] +    d[sum_a] += 1