n = gets.chomp.to_i

as = gets.chomp.split.map{ |x| x.to_i }

#自分以外の約数(1含む)
yakusu = []

max = (n**0.5).floor

(1..n).each{ |i|
	yakusu[i] = {1 => true}

	(2..max).each{ |x|
		if i % x == 0 && x != i then
			yakusu[i][x] = true
			yakusu[i][i / x] = true
		end
	}
}

result = []

n.downto(1){ |x|
	if as[x - 1] == 1 then
		result << x

		if yakusu[x] != nil then
			yakusu[x].keys.each { |k|
				if as[k - 1] == 1 then
					as[k - 1] = 0
				else
					as[k - 1] = 1
				end
			}
		end
	end
}

puts result.size
puts result
