import Control.Monad
import Data.Array.IO
import Data.Bits
import Data.List
import Debug.Trace

main = do
    n <- read <$> getLine
    a <- map read <$> words <$> getLine
    a <- newListArray (1, n) a
    r <- solve n a
    putStrLn $ show $ length r
    putStrLn $ intercalate " " $ map show $ r


solve :: Int -> IOArray Int Int -> IO [Int]
solve n a = do
    b <- (flip filterM) [n, n - 1 .. 1] $ \i -> do
        b <- readArray a i
        if b == 1 then do
            let s = (floor . sqrt . fromIntegral) i
            forM_ [1 .. s] $ \j -> do
                if i /= 1 && i `mod` j == 0 then do
                    flipValue a j
                    if j /= 1 && (j /= s || i /= s * s) then do
                        flipValue a (i `div` j)
                    else return ()
                else return ()
            return True
        else
            return False
    return $ reverse b

flipValue a j = readArray a j >>= \c -> writeArray a j (1 - c)