import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.STRef

exec_ :: Monad m => (a -> m b) -> (b -> Bool) -> (a -> b -> m ()) -> [a] -> m ()
exec_ s p f []     = return ()
exec_ s p f (x:xs) = do
    a <- s x
    when (p a) $ do { f x a; exec_ s p f xs }

shell :: [Int] -> Int -> [Int] -> (Int, [Int])
shell xs n gs = runST $ do
    cnt <- newSTRef 0
    ys  <- newListArray (0, n - 1) xs :: ST s (STUArray s Int Int)
    forM_ gs $ \g -> do
        forM_ [g .. n - 1] $ \i -> do
            v  <- readArray ys i
            c1 <- readSTRef cnt
            exec_ (readArray ys) (v <) (\j w -> do { writeArray ys (j + g) w; modifySTRef cnt (+ 1) }) [i - g, i - g * 2 .. 0]
            c2 <- readSTRef cnt
            when (c1 /= c2) $ writeArray ys (i - g * (c2 - c1)) v
    c  <- readSTRef cnt
    es <- getElems ys
    return (c, es)

main :: IO ()
main = do
    (n:xs) <- map read . lines <$> getContents
--  let gs      = filter (<= n) [1750, 701, 301, 132, 57, 23, 10, 4, 1]         -- A102549
    let gs      = reverse $ takeWhile (<= n) [(3 ^ i - 1) `div` 2| i <- [1 ..]] -- A003462
    let (c, ys) = shell xs n gs
    print $ length gs
    putStrLn $ unwords $ map show gs
    print c
    putStr $ unlines $ map show ys