object Main extends App{
    // Your code here!
    import scala.io.StdIn
    def sort(a: Array[Int], n: Int):Array[Int] = {
        for(i <- 0 until a.length) {
            var v = a(i)
            var j = i - 1
            while(j >= 0 && a(j) > v) {
                a(j+1) = a(j)
                j -= 1
            }
            a(j+1) = v
            print(a.mkString(" ") + "\n")
        }
        a
    }
    val inputN = io.StdIn.readLine().toInt
    val inputArray = io.StdIn.readLine().split(" ").map{_.toInt}
    sort(inputArray, inputN)
}

