import java.io.BufferedReader
import java.io.InputStreamReader

var cnt = 0

fun insertionSort(a: IntArray, g: Int) {
    for (i in g until a.size) {
        val pivotVal = a[i]
        var pivotIdx = i-g
        while (pivotIdx >= 0 && a[pivotIdx] > pivotVal) {
            a[pivotIdx+g] = a[pivotIdx]
            pivotIdx -= g
            cnt++
        }
        a[pivotIdx+g] = pivotVal
    }
}

fun shellSort(a: IntArray): List<Int> {
    val gs = generateSequence(seed = 1, nextFunction = { 3 * it + 1 })
            .takeWhile { it <= a.size }
            .toList()

    for (i in gs.size-1 downTo 0) {
        insertionSort(a, gs[i])
    }

    return gs
}

fun main(args: Array<String>) {
    val a = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .drop(n = 1)
            .map { it.toInt() }
            .toIntArray()

    val gs = shellSort(a)
    println(gs.size)
    println(gs.reversed().joinToString(" "))
    println(cnt)
    println(a.joinToString("\n"))
}
