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

myTakeWhileM :: Monad m => (a -> m b) -> (b -> Bool) -> [a] -> m [(a, b)]
myTakeWhileM s p []     = return []
myTakeWhileM s p (x:xs) = do
    a <- s x
    if p a then do { ys <- myTakeWhileM s p xs; return ((x, a) : ys)} else return []

shell :: [Int] -> Int -> [Int] -> (Int, [Int])
shell xs n gs = runST $ do
    c  <- newSTRef 0
    ys <- newListArray (0, n - 1) xs :: ST s (STUArray s Int Int)
    forM_ gs $ \g -> do
        forM_ [g .. n - 1] $ \i -> do
            let is = [i - g, i - g * 2 .. 0]
            v  <- readArray ys i
            zs <- myTakeWhileM (\j -> readArray ys j) (\y -> v < y) [i - g, i - g * 2 .. 0]
            c1 <- readSTRef c
            forM_ zs $ \(j, z) -> do
                writeArray ys (j + g) z
                modifySTRef c (+ 1)
            c2 <- readSTRef c
            writeArray ys (i - g * (c2 - c1)) v
    n  <- readSTRef c
    es <- getElems ys
    return (n, es)

main :: IO ()
main = do
    n  <- readLn
    xs <- replicateM n readLn
    let gs      = filter (<= n) [1750, 701, 301, 132, 57, 23, 10, 4, 1] -- A102549
    let (c, ys) = shell xs n gs
    print $ length gs
    putStrLn $ unwords $ map show gs
    print c
    putStr $ unlines $ map show ys