import Control.Monad
import Control.Monad.ST
import Debug.Trace
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV


main = do
    n <- head . unfoldr BS.readInt <$> BS.getLine
    a <- UV.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let ans = foldl' (sub4 a) V.empty [n, n-1..1]
    if length ans == 0
    then print 0
    else putStrLn $ (unwords . V.toList . V.map show) ans

sub4 :: UV.Vector Int -> V.Vector Int -> Int -> V.Vector Int
sub4 ls s i | ns        = runST $ do
                            s_ <- V.thaw s
                            s_ <- MV.grow s_ 1
                            MV.write s_ (MV.length s_ - 1) i
                            V.freeze s_
            | otherwise = s
    where b = ls UV.! (i - 1)
          ns = V.length (V.filter (\x -> x `mod` i == 0) s) `mod` 2 /= b
