import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
f = np.empty([n,n])

f[0] = np.cumsum(a)
count = list(f[0]).count(0)

for i in range(1,n):
    f[i] = f[i-1] - a[i-1]
    count += list(f[i][i:]).count(0)
print(count)