/**
 * 挿入ソート
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()
}

class Main {

    companion object {

        // 連結リスト
        private lateinit var list: MutableList<Int>
        private var size: Int = 0

        fun init() {

            size = readLine()!!.toInt()

            val inputs = readLine()!!.split(" ")

            list = inputs.map {
                it.toInt()
            }.toMutableList()
        }

        fun execute() {
            for (index in 0 until size) {
                var targetIndex = index

                for (compareIndex in 0 until targetIndex) {
                    if (list[targetIndex] < list[compareIndex]) {
                        // 交換
                        val temp = list[targetIndex]
                        list.removeAt(targetIndex)
                        list.add(compareIndex, temp)
                        break
                    }
                }

                println(list.joinToString(" "))
            }
        }
    }
}


