import scala.io.StdIn.{readInt, readLong};

object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val arr = (0 until n).map(a => readLong).toArray;
        val interval = fetchInterval(n);
        val cnt = shellSort(arr, n, interval);
        println(interval.length);
        println(interval.mkString(" "));
        println(cnt);
        println(arr.mkString("\n"));
    }
    
    def fetchInterval(n: Int): List[Int] = { 
        def go(g: Int, ret: List[Int]): List[Int] = {
            val ng = (g * 3) + 1;
            if (ng < n) go(ng, ng :: ret) else ret;
        }
        go(0, Nil);
    }
    
    def shellSort(arr: Array[Long], n: Int, interval: List[Int]): Int = {
        interval.foldLeft(0) { (cnt, i) =>
            (0 until n).foldLeft(cnt) { (cnt, j) =>
                insertionSort(arr, j, i) + cnt;
            }
        }
    }
    
    def insertionSort(arr: Array[Long], index: Int, interval: Int): Int = {
        val insert = arr(index);
        var cnt = 0;
        def go(curr: Int): Unit = {
            val prev = curr - interval;
            if (prev < 0 || arr(prev) <= insert) {
                arr(curr) = insert;
            } else {
                arr(curr) = arr(prev);
                cnt += 1;
                go(prev);
            }
        }
        go(index);
        cnt
    }
}
