from _collections import defaultdict

n=int(eval(input()))

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



X=[A[0]]

for i in range(1,n):

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

Y=defaultdict(int)

for x in X:

    Y[x]+=1

ans=0

for y in list(Y.values()):

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

print((ans+Y[0]))
from collections import Counter

from itertools import accumulate

n=int(eval(input()))

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

Y=Counter(A)

ans=0

for y in list(Y.values()):

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

print((ans+Y[0]))
from _collections import defaultdict

n = int(eval(input()))
A = list(map(int, input().split()))
X = [A[0]]
for i in range(1, n):
    X.append(X[-1] + A[i])
Y = defaultdict(int)
for x in X:
    Y[x] += 1
ans = 0
for y in list(Y.values()):
    ans += (y - 1) * y // 2
print((ans + Y[0]))

from collections import Counter
from itertools import accumulate

n = int(eval(input()))
A = accumulate(list(map(int, input().split())))
Y = Counter(A)
ans = 0
for y in list(Y.values()):
    ans += (y - 1) * y // 2
print((ans + Y[0]))

-from _collections import defaultdict +from collections import Counter +from itertools import accumulate -A = list(map(int, input().split())) -X = [A[0]] -for i in range(1, n): -    X.append(X[-1] + A[i]) -Y = defaultdict(int) -for x in X: -    Y[x] += 1 +A = accumulate(list(map(int, input().split()))) +Y = Counter(A)