fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map {
        readLine()!!.toInt()
    }

    val gs = gaps(n)

    val (ys, cnt) = shellSort(xs, gs)

    println(gs.size)
    println(gs.joinToString(" "))
    println(cnt)
    ys.forEach {
        println(it)
    }
}

private fun gaps(n: Int): List<Int> {
    return generateSequence(1, { it * 3 + 1 })
            .takeWhile { it <= n }
            .toList()
            .reversed()
}

private fun shellSort(xs: List<Int>, gs: List<Int>): Pair<List<Int>, Int> {

    var cnt = 0

    fun insertionSort(xs: List<Int>, g: Int): List<Int> {
        val n = xs.size
        val ys = xs.toMutableList()

        for (i in g until n) {
            val v = ys[i]
            var j = i - g
            while (j >= 0 && ys[j] > v) {
                ys[j + g] = ys[j]
                j -= g
                cnt++
            }
            ys[j + g] = v
        }

        return ys
    }

    var ys = xs
    gs.forEach {
        ys = insertionSort(ys, it)
    }

    return Pair(ys, cnt)
}
