from collections import Counter

from itertools import accumulate



n = int(eval(input()))

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



a_cum = list(accumulate(a))

cnt = Counter(a_cum)



ans = 0

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

    if k == 0:

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

    elif v > 0:

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

        

print(ans)
from collections import Counter

from itertools import accumulate



n = int(eval(input()))

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



cnt = Counter(list(accumulate(a)))



ans = 0

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

    if k == 0:

        ans += v

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

print(ans)
from collections import Counter
from itertools import accumulate

n = int(eval(input()))
a = list(map(int, input().split()))
a_cum = list(accumulate(a))
cnt = Counter(a_cum)
ans = 0
for k, v in list(cnt.items()):
    if k == 0:
        ans += v + v * (v - 1) // 2
    elif v > 0:
        ans += v * (v - 1) // 2
print(ans)

from collections import Counter
from itertools import accumulate

n = int(eval(input()))
a = list(map(int, input().split()))
cnt = Counter(list(accumulate(a)))
ans = 0
for k, v in list(cnt.items()):
    if k == 0:
        ans += v
    ans += v * (v - 1) // 2
print(ans)

-a_cum = list(accumulate(a)) -cnt = Counter(a_cum) +cnt = Counter(list(accumulate(a))) -        ans += v + v * (v - 1) // 2 -    elif v > 0: -        ans += v * (v - 1) // 2 +        ans += v +    ans += v * (v - 1) // 2