import functools
import operator
import math
n = int(input())
a = list(map(int, input().split()))


b = [0 for _ in range(n)]
b[0] = a[0]
for i in range(1, n):
    b[i] = b[i - 1] + a[i]

# print(b)


def nCr(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    numer = functools.reduce(operator.mul, range(n, n - r, -1))
    denom = functools.reduce(operator.mul, range(1, r + 1))
    return numer // denom


def bf3(n, b):
    c = {}
    for bi in b:
        if bi in c:
            c[bi] = c[bi] + 1
        else:
            c[bi] = 1
    # print(c)
    cnt = 0
    for k in c.keys():
        ci = c[k]
        if k == 0:
            cnt += math.factorial(ci)
        elif ci >= 2:
            cnt += nCr(ci, 2)
    return cnt


def bf2(n, b):
    cnt = 0
    for i in range(n):
        s = b[i]
        if s == 0:
            cnt += 1
        for j in range(i):
            if s - b[j] == 0:
                cnt += 1
    return cnt


def bf(n, a):
    cnt = 0
    for i in range(n + 1):
        for j in range(i):
            s = 0
            for k in range(j, i):
                s += a[k]
            if s == 0:
                cnt += 1
    return cnt


print(bf3(n, b))
# print(bf2(n, b))
# print(bf(n, a))
