import Control.Monad
import Control.Monad.ST
import Data.Array.ST

insertion :: [Int] -> Int -> Int -> (Int, [Int])
insertion xs n g = runST $ do
    ys <- newListArray (0, n - 1) xs :: ST s (STUArray s Int Int)
    cs <- forM [g .. n - 1] $ \i -> do
        let is = [i - g, i - g * 2 .. 0]
        v  <- readArray ys i
        zs <- mapM (\j -> readArray ys j) is
        let ts = filter (\(j, z) -> v < z) $ zip is zs
        cs <- forM ts $ \(j, z) -> do
            writeArray ys (j + g) z
            return 0
        writeArray ys (i - g * length ts) v
        return (length cs)
    fmap ((,) (foldl (+) 0 cs)) (getElems ys)

shell :: [Int] -> Int -> [Int] -> (Int, [Int])
shell xs n gs = foldl (\(c, ys) g -> let (d, zs) = insertion ys n g in (c + d, zs)) (0, xs) gs

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