def getsum(i,j):
	global memo
	#v = sum(a[i:j])
	#print('i:{}, j:{}'.format(i,j))
	if memo[i][j-1] != None:
		return memo[i][j-1]
	if i==0:
		v = sum(a[i:j])
	else:
		v = getsum(i-1,j) - a[i-1]
	memo[i][j-1] = v
	return v

if __name__ == '__main__':
	n = int(input())
	a = list(map(int, input().split()))

	count = 0
	memo = [[None] * n for i in range(n)]

	for i in range(n):
		for j in range(i+1,n+1):
			v = getsum(i,j)
			#v = getsum(i-1,j) - a[i-1]
			if v==0:
				count+=1

	print(count)