fun main(args: Array<String>) {
    val nNum = readLine()!!.toInt()
    val numLine = readLine()!!
    val numbers = numLine.split(" ").map { s -> s.toInt() }.toIntArray()

    printNumbers(numbers)
    for (i in 1..nNum-1) {
        val value = numbers[i]
        var j = i-1
        while (j >= 0 && numbers[j] > value) {
            numbers[j+1] = numbers[j]
            j--
        }
        numbers[j+1] = value

        printNumbers(numbers)
    }
}

private fun printNumbers(numbers: IntArray) {
    for (i in 0..numbers.size-1) {
        print(numbers[i])
        if (i != numbers.size-1) {
            print(" ")
        }
    }
    println()
}
