from bisect import *
import numpy

a = input()
a = input().split()
# a = [1, 3, -4, 2, 2, -2]
# a = [1, -1, 1, -1, 1, -1, 1]
# a = [1, -2, 3, -4, 5]
a = [int(i) for i in a]
a = numpy.array(a)
b = numpy.cumsum(a)

cnt = len(b) - numpy.count_nonzero(b)

idx = numpy.argsort(b)
c = list(numpy.sort(b))

for xi, x in enumerate(c):
    i = bisect_left(c, x)
    if i == len(c) or (i == 0 and c[0] != x):
        continue
    j = bisect_right(c, x)
    if j == 0 or (j == len(c) and c[-1] != x):
        continue
    for n in range(i, j):
        if idx[n] > idx[xi]:
            cnt += 1
print(cnt)
