var cnt:Int = 0

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val arr: Array<Int> = Array(n) {
        readLine()!!.toInt()
    }
    shellSort(arr,n)
    //val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    //insertionSort(list.toIntArray(),n,2)
}
fun shellSort(A:Array<Int>, n:Int)
{
    var G =  gaps(n)
    var m = G.count()
    var R:Array<Int> = A
    println(m)
    println(G.joinToString(" "))

    for (i in (0..(m-1)))
    {
        R=insertionSort(A, n, G[i])
    }
    println(cnt)
    for (i in (0..(R.count() - 1)))
    {
        println(R[i])
    }
}
private fun gaps(n: Int): List<Int> {
    return generateSequence(1, { it * 3 + 1 })
            .takeWhile { it <= n }
            .toList()
            .reversed()
}
fun  insertionSort(A:Array<Int>, n:Int, g:Int):Array<Int>
{
    var v:Int
    var j:Int
    for (i in (g .. (n-1)))
    {
        v = A[i]
        j = i - g
        while (j >= 0 && A[j] > v)
        {
            A[j+g] = A[j]
            j = j - g
            cnt++
            A[j+g] = v
        }
    }
    return A
}


