N = gets.chomp.to_i
a = [nil] + gets.chomp.split(" ").map(&:to_i)
insert = Array.new(N + 1, 0)
a.each_with_index.reverse_each do |val, i|
    next if i == 0
    if N < i * 2
        insert[i] = a[i]
    else
        buf = 0
        for j in 2..(N / i)
            buf = buf ^ insert[i * j]
        end
        insert[i] = buf ^ a[i]
    end
end
puts insert.inject(:+)
puts insert.zip((0..N).to_a).select{|val, i| val == 1}.map{|val, i| i}.join(" ") if insert.uniq.size == 2