from collections import defaultdict

import math



def combnations(n, r):

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



N = int(eval(input()))

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

rui = [0] * (N + 1)

for i in range(N):

    rui[i + 1] = rui[i] + a[i]



d = defaultdict(int)

for key in rui:

    d[key] += 1



sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True)



cnt = 0

for i, j in sortd:

    if j >= 2:

        cnt += combnations(j, 2)

    else:

        break

print(cnt)
from collections import defaultdict



N = int(eval(input()))

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

rui = [0] * (N + 1)

for i in range(N):

    rui[i + 1] = rui[i] + a[i]



d = defaultdict(int)

for key in rui:

    d[key] += 1



sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True)



cnt = 0

for i, j in sortd:

    if j >= 2:

        cnt += (j * (j - 1) // 2)

print(cnt)
from collections import defaultdict
import math


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


N = int(eval(input()))
a = list(map(int, input().split()))
rui = [0] * (N + 1)
for i in range(N):
    rui[i + 1] = rui[i] + a[i]
d = defaultdict(int)
for key in rui:
    d[key] += 1
sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True)
cnt = 0
for i, j in sortd:
    if j >= 2:
        cnt += combnations(j, 2)
    else:
        break
print(cnt)

from collections import defaultdict

N = int(eval(input()))
a = list(map(int, input().split()))
rui = [0] * (N + 1)
for i in range(N):
    rui[i + 1] = rui[i] + a[i]
d = defaultdict(int)
for key in rui:
    d[key] += 1
sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True)
cnt = 0
for i, j in sortd:
    if j >= 2:
        cnt += j * (j - 1) // 2
print(cnt)

-import math - - -def combnations(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - -        cnt += combnations(j, 2) -    else: -        break +        cnt += j * (j - 1) // 2