from collections import Counter

n = int(eval(input()))

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



cum = [0] * (n + 1)

for i in range(n):

    cum[i + 1] = cum[i] + a[i]



c = Counter(cum)

ans = 0

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

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

print(ans)
from itertools import accumulate

from collections import Counter



N = int(eval(input()))

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

Acum = list(accumulate(A))

C = Counter(Acum)



ans = 0

for _, v in list(C.items()):

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

print(ans)

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
cum = [0] * (n + 1)
for i in range(n):
    cum[i + 1] = cum[i] + a[i]
c = Counter(cum)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

from itertools import accumulate
from collections import Counter

N = int(eval(input()))
A = [0] + list(map(int, input().split()))
Acum = list(accumulate(A))
C = Counter(Acum)
ans = 0
for _, v in list(C.items()):
    ans += (v - 1) * v // 2
print(ans)

+from itertools import accumulate -n = int(eval(input())) -a = list(map(int, input().split())) -cum = [0] * (n + 1) -for i in range(n): -    cum[i + 1] = cum[i] + a[i] -c = Counter(cum) +N = int(eval(input())) +A = [0] + list(map(int, input().split())) +Acum = list(accumulate(A)) +C = Counter(Acum) -for v in list(c.values()): -    ans += v * (v - 1) // 2 +for _, v in list(C.items()): +    ans += (v - 1) * v // 2