n = gets.to_i
as = gets.split.map(&:to_i)

total = 0
balls = []
(n-1).downto(0) do |i|
  if as[i] == 0 && total.even? || as[i] == 1 && total.odd?
    balls.unshift(0)
  else
    balls.unshift(1)
    total += 1
  end
end

puts balls.count(1)
ans = []
balls.each_with_index do |ball, i|
  if ball == 1
    ans << i + 1
  end
end
if !ans.empty?
  puts ans.join(" ")
end