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]


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(bf2(n, b))
# print(bf(n, a))
