fun main(args: Array<String>) {
    val array = IntArray(readLine()?.toInt() ?: 0) {
        readLine()?.toInt() ?: -1
    }
    shellSort(array)
}

fun insertionSort(array: IntArray, g: Int, cnt: Int): Int {
    var counter = cnt
    for (i in g until array.size) {
        val v = array[i]
        var j = i - g
        while (j >= 0 && array[j] > v) {
            array[j + g] = array[j]
            j -= g
            counter++
        }
        array[j + g] = v
    }
    return counter
}

fun shellSort(array: IntArray) {
    val gArray = arrayListOf(1)
    for (i in 1 until array.size) {
        val h = gArray[i-1] * 3 + 1
        if (h > array.size) {
            break
        }
        gArray.add(h)
    }
    println(gArray.size)
    println(gArray.reversed().joinToString(" "))
    var cnt = 0
    for (g in gArray.reversed()) {
        cnt = insertionSort(array, g, cnt)
    }
    println(cnt)
    println(array.joinToString("\n"))
}
