import scala.io.StdIn.{readLong, readInt}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = (1 to len).toArray.map(a => readLong)
        println(shellSort(arr, len).mkString("\n"))
    }
    
    def shellSort(arr: Array[Long], len: Int): Array[Long] = {
        val copy = new Array[Long](len)
        arr.copyToArray(copy)
        var cnt = 0
        val groups = genGroups(len).reverse
        println(groups.length + "\n" + groups.mkString(" "))
        for (g <- groups) {
            for (start <- (0 until g)) {
                cnt += insertionSort(copy, start, len, g)
            }
        } 
        println(cnt)
        copy
    }
    
    def insertionSort(arr: Array[Long], start: Int, len: Int, group: Int): Int = {
        var cnt = 0
        def insert(target: Long, ptr: Int): Unit = ptr match {
            case a if (a < 0 || arr(ptr) <= target) => arr(ptr + group) = target
            case a => {
                cnt += 1
                arr(ptr + group) = arr(ptr)
                insert(target, ptr - group)
            }
        }
        for (targetIndex <- Range(start, len, group)) { insert(arr(targetIndex), targetIndex - group)}
        cnt
    }
    
    def genGroups(len: Int): List[Int] =  {
        def go(len: Int, glen: Int, next: Int): List[Int] = next match {
            case a if (a == 1) || (a < len && glen < len) => a :: go(len, glen + 1, a * 3 + 1)
            case a => Nil
        }
        go(len, 0, 1)
    }
}
