import sys,math,collections,itertools

input = sys.stdin.readline



N=int(eval(input()))

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

A =[0]

for i in range(N):

    A.append(A[-1]+a[i])



Ac = collections.Counter(A)

cnt = 0

for val in list(Ac.values()):

    cnt += val*(val-1)//2

print(cnt)

import sys,collections,itertools

input = sys.stdin.readline

N=int(eval(input()))

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

A =[0]+list(itertools.accumulate(a))

Ac = collections.Counter(A)

cnt = 0

for val in list(Ac.values()):

    cnt += val*(val-1)//2

print(cnt)
import sys, math, collections, itertools

input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
A = [0]
for i in range(N):
    A.append(A[-1] + a[i])
Ac = collections.Counter(A)
cnt = 0
for val in list(Ac.values()):
    cnt += val * (val - 1) // 2
print(cnt)

import sys, collections, itertools

input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
A = [0] + list(itertools.accumulate(a))
Ac = collections.Counter(A)
cnt = 0
for val in list(Ac.values()):
    cnt += val * (val - 1) // 2
print(cnt)

-import sys, math, collections, itertools +import sys, collections, itertools -A = [0] -for i in range(N): -    A.append(A[-1] + a[i]) +A = [0] + list(itertools.accumulate(a))