from itertools import accumulate

from collections import Counter



n = int(eval(input()))

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

L = [0] + list(accumulate(A))

C = Counter(L)

ans = 0

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

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

print(ans)
from itertools import accumulate

from collections import Counter



n = int(eval(input()))

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

A = list(accumulate(A))

C = Counter(A)

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 = list(map(int, input().split()))
L = [0] + list(accumulate(A))
C = Counter(L)
ans = 0
for i in list(C.values()):
    ans += i * (i - 1) // 2
print(ans)

from itertools import accumulate
from collections import Counter

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

-A = list(map(int, input().split())) -L = [0] + list(accumulate(A)) -C = Counter(L) +A = [0] + list(map(int, input().split())) +A = list(accumulate(A)) +C = Counter(A) -for i in list(C.values()): -    ans += i * (i - 1) // 2 +for v in list(C.values()): +    ans += v * (v - 1) // 2