from collections import Counter



N = int(eval(input()))

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



A_sum = [A[0]]

for i in range(1,N):

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

    



a_cnt = Counter(A_sum)





ans = 0

for k,v in list(a_cnt.items()):

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

    if k==0:

        ans += v

    

print(ans)
from collections import Counter

from itertools import accumulate



N = int(eval(input()))

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



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



cnt = Counter(B)



ans = 0

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

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

    

print(ans)
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
A_sum = [A[0]]
for i in range(1, N):
    A_sum.append(A_sum[i - 1] + A[i])
a_cnt = Counter(A_sum)
ans = 0
for k, v in list(a_cnt.items()):
    ans += v * (v - 1) // 2
    if k == 0:
        ans += v
print(ans)

from collections import Counter
from itertools import accumulate

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

+from itertools import accumulate -A_sum = [A[0]] -for i in range(1, N): -    A_sum.append(A_sum[i - 1] + A[i]) -a_cnt = Counter(A_sum) +B = [0] + list(accumulate(A)) +cnt = Counter(B) -for k, v in list(a_cnt.items()): +for v in list(cnt.values()): -    if k == 0: -        ans += v