import java.util.*

fun insertionSort(A: Array<Int>, n: Int, g: Int): Int {
    var cnt = 0
    for (i in g until n) {
        val v = A[i]
        var j = i - g
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j]
            j = j - g
            cnt++
        }
        A[j + g] = v
    }
    return cnt
}

fun shellSort(A: Array<Int>, n: Int): Int {
    var cnt = 0
    val G = mutableListOf<Int>()
    var g = 1
    while (g <= n) {
        G.add(g)
        g += g * 3
    }
    G.reverse()
    println(G.size)
    println(G.joinToString(" "))
    for (i in 0 until G.size) {
        cnt += insertionSort(A, n, G[i])
    }
    println(cnt)
    A.forEach { println(it) }
    return cnt
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val list = mutableListOf<Int>()
    (1..n).forEach {
        list.add(scanner.nextInt())
    }
    list.toTypedArray()
    shellSort(list.toTypedArray(), n)
}
