from collections import Counter



N = int(eval(input()))

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



ans = 0

ruisekiwa = [0] * (N+1)



for i in range(N):

    ruisekiwa[i+1] = ruisekiwa[i] + inputs[i]



ruisekiwa = ruisekiwa[1:]

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))

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

N = int(eval(input()))
inputs = [int(i) for i in input().split()]
ans = 0
ruisekiwa = [0] * (N + 1)
for i in range(N):
    ruisekiwa[i + 1] = ruisekiwa[i] + inputs[i]
ruisekiwa = ruisekiwa[1:]
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))
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 itertools import accumulate -ruisekiwa = [0] * (N + 1) -for i in range(N): -    ruisekiwa[i + 1] = ruisekiwa[i] + inputs[i] -ruisekiwa = ruisekiwa[1:] +ruisekiwa = list(accumulate(inputs))