from collections import Counter

import math



def nCr(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))





n = int(eval(input()))

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

a_t = [0]

for i in range(n):

    a_t.append(a[i] + a_t[i])

ac = Counter(a_t[1:])

ans = 0

for i in ac:

    if i == 0:

        ans += ac[i]

    if ac[i] > 1:

        ans += nCr(ac[i], 2)

print(ans)
import collections



n = int(eval(input()))

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

a_t = [0]

for i in range(n):

    a_t.append(a[i] + a_t[i])

a_t = collections.Counter(sorted(a_t))

ans = 0

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

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

print(ans)

from collections import Counter
import math


def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(eval(input()))
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
ac = Counter(a_t[1:])
ans = 0
for i in ac:
    if i == 0:
        ans += ac[i]
    if ac[i] > 1:
        ans += nCr(ac[i], 2)
print(ans)

import collections

n = int(eval(input()))
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = collections.Counter(sorted(a_t))
ans = 0
for i in list(a_t.values()):
    ans += i * (i - 1) // 2
print(ans)

-from collections import Counter -import math - - -def nCr(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - +import collections -ac = Counter(a_t[1:]) +a_t = collections.Counter(sorted(a_t)) -for i in ac: -    if i == 0: -        ans += ac[i] -    if ac[i] > 1: -        ans += nCr(ac[i], 2) +for i in list(a_t.values()): +    ans += i * (i - 1) // 2