N = gets.chomp.to_i
constrains = gets.chomp.split.map &:to_i
constrains.unshift(0)

boxes = [0] * (N+1)
N.downto(1) do |i|
    context = i.step(N, i).reduce(0) { |s, o| s + boxes[o] } % 2
    boxes[i] = constrains[i] ^ context 
end

is_good = N.downto(1).reduce(true) do |is_good, i|
    context = i.step(N, i).reduce(0) { |s, o| s + boxes[o] } % 2
    break false if context != constrains[i]
    true
end

# p boxes
# p is_good

if is_good
    puts boxes.count(1)
    if boxes.count(1) > 0
        ball_indexes = []
        boxes.map.with_index { |v, i| ball_indexes.push(i) if v == 1 }
        puts ball_indexes.join(" ")
    end
else
    puts -1
end
