fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    insertionSort(list.toIntArray(),n)
}

fun insertionSort(A:IntArray, N:Int) // N個の要素を含む0-オリジンの配列A
{
    var v:Int
    println(A.joinToString(" "))
    for (i in (1..(N - 1))) {
        v = A[i]
        var j:Int = i - 1
        while ((j >= 0) && (A[j] > v)) {
            A[j + 1] = A[j]
            j--
        }
        A[j + 1] = v
        println(A.joinToString(" "))
    }
}
