def nCr(n, r):
    r = min(r, n-r)

    X = 1
    for i in range(n, n-r, -1):
        X *= i

    Y = 1
    for i in range(r, 1, -1):
        Y *= i

    return X//Y

N = int(input())
A = list(map(int, input().split()))
B = [0]
t = 0
for i in range(N):
    B.append(B[i] + A[i])

C = set(B)
for j in C:
    count = B.count(j)
    if count > 1:
        t += nCr(count,2)

print(t)