n = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...


#print(n, A)

L=[]
L.append([A[0]])
#print(L)

count=0
for i in range(1,n):
	a = int(A[i])
	l = list(L[i-1])
	l = list(map(lambda x: int(x)+a, l))

	count+=l.count(0)

	l.append(a)
	L.append(l)
	

print(count)
