from collections import defaultdict

N = int(eval(input()))

A = [int(i) for i in input().split()]



d = defaultdict(int)



d[0] = 1

sum = 0

for i in range(N):

    sum += A[i]

    d[sum] += 1



ans = 0

for v in list(d.values()):

    if v >= 2:

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



print(ans)

import collections

N = int(eval(input()))

A = [int(i) for i in input().split()]



S = [0]

for a in A:

    S.append(S[-1]+a)



C = collections.Counter(S)



ans = 0

for v in list(C.values()):

    if v >= 2:

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

print(ans)

from collections import defaultdict

N = int(eval(input()))
A = [int(i) for i in input().split()]
d = defaultdict(int)
d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += (v * (v - 1)) // 2
print(ans)

import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0]
for a in A:
    S.append(S[-1] + a)
C = collections.Counter(S)
ans = 0
for v in list(C.values()):
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

-from collections import defaultdict +import collections -d = defaultdict(int) -d[0] = 1 -sum = 0 -for i in range(N): -    sum += A[i] -    d[sum] += 1 +S = [0] +for a in A: +    S.append(S[-1] + a) +C = collections.Counter(S) -for v in list(d.values()): +for v in list(C.values()): -        ans += (v * (v - 1)) // 2 +        ans += v * (v - 1) // 2