N = int(input())
A = [int(i) for i in input().split()]
s=n=0
c=A[0]
for i in range(N):
	if A[i]==0: s+=1
for i in range(1, N):
	n = c+A[i]
	for j in range(i, N):
		c += A[j]
		if c==0: s+=1
		c -= A[j-i]
	c = n
print(s)