import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST

divisor :: Int -> [Int]
divisor n = sub 1
  where
    sub i | i > (ceiling (sqrt $ fromIntegral n)) = []
          | n `mod` i == 0 = i : (n `div` i) : (sub (i+1))
          | otherwise = sub (i+1)

main :: IO ()
main = do
  n <- readLn :: IO Int
  as' <- map read.words <$> getLine :: IO [Int]

  let as = V.fromList as'
      nums = runST $ do
        vec <- VM.replicate n False

        fmap (filter (> 0)) $ forM [n,n-1..1] $ \i -> do
          let ai = as V.! (i-1)
          b <- VM.read vec (i-1)
          if b && ai == 1 || (not b) && ai == 0 then return (-1)
            else do
              forM_ (divisor i) $ \d -> do
                b0 <- VM.read vec (d-1)
                if b0 then VM.write vec (i-1) False else VM.write vec (i-1) True
              return i

  print $ length nums
  forM nums $ \k -> do
    putStr $ (show k) ++ " "
  putStrLn ""
