import scala.io.StdIn._

object Main extends App {

  def display(a: Array[Int]) {
    a.zipWithIndex.foreach{ case (x, i) => {
      print(x)
      if (i+1 != a.length) print(" ")
    }}
    println()
  }

  def insertionSort(a: Array[Int], n: Int) {
    for (i <- (1 to n-1)) {
      var x = a(i)
      var j = i - 1
      while (j >= 0 && a(j) > x) {
        a(j+1) = a(j)
        j -= 1
      }
      a(j+1) = x
      display(a)
    }
    
  }

  val n = readLine.toInt
  val a = readLine.split(" ")
                  .map(s => s.toInt)
                  .toArray
  display(a)
  insertionSort(a, n)
}
