from collections import Counter

from itertools import accumulate



N = int(eval(input()))

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



ans = 0



ruisekiwa = list(accumulate(inputs))

ruisekiwa.sort()

counter_ruiseki = Counter(ruisekiwa)



for key, value in list(counter_ruiseki.items()):

    if key == 0 and value == 1:

        ans += value

        continue

    elif key == 0 and value > 1:

        ans += value

    if value > 1:

        ans += sum(list(range(value)))



print(ans)

from collections import Counter

from itertools import accumulate



N = int(eval(input()))

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



ans = 0



ruisekiwa = list(accumulate(inputs))



for key, value in list(Counter(ruisekiwa).items()):

    if key == 0 and value == 1:

        ans += value

        continue

    elif key == 0 and value > 1:

        ans += value

    if value > 1:

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



print(ans)

from collections import Counter
from itertools import accumulate

N = int(eval(input()))
inputs = [int(i) for i in input().split()]
ans = 0
ruisekiwa = list(accumulate(inputs))
ruisekiwa.sort()
counter_ruiseki = Counter(ruisekiwa)
for key, value in list(counter_ruiseki.items()):
    if key == 0 and value == 1:
        ans += value
        continue
    elif key == 0 and value > 1:
        ans += value
    if value > 1:
        ans += sum(list(range(value)))
print(ans)

from collections import Counter
from itertools import accumulate

N = int(eval(input()))
inputs = [int(i) for i in input().split()]
ans = 0
ruisekiwa = list(accumulate(inputs))
for key, value in list(Counter(ruisekiwa).items()):
    if key == 0 and value == 1:
        ans += value
        continue
    elif key == 0 and value > 1:
        ans += value
    if value > 1:
        ans += value * (value - 1) // 2
print(ans)

-ruisekiwa.sort() -counter_ruiseki = Counter(ruisekiwa) -for key, value in list(counter_ruiseki.items()): +for key, value in list(Counter(ruisekiwa).items()): -        ans += sum(list(range(value))) +        ans += value * (value - 1) // 2