import Control.Monad
import Control.Monad.ST
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.fromList . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let ans = foldl' (\x y -> sub4 y a x) V.empty (reverse [0.. UV.length a - 1])
    if length ans == 0
    then print 0
    else putStrLn $ (unwords . V.toList . V.map show) ans

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