import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- VU.fromList <$> getIntList
    let ans = VU.toList $ solve n as
    print $ sum ans
    putStrLn . unwords $ zipWith (\i a -> if a==1 then show i else "") [1..] ans

solve n as = VU.create $ do
    vec <- VUM.replicate n 0
    forM [n,n-1..1] $ \i -> do
        ai' <- (`mod` 2) . sum <$> mapM (VUM.read vec) [i-1,2*i-1..n-1]
        VUM.write vec (i-1) ((as VU.! (i-1)) - ai')
    return vec