object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val a = io.StdIn.readLine().split(" ").map(_.toInt)

    insertionSort(a, n)(arr => println(arr.mkString(" ")))
  }

  def insertionSort(a: Array[Int], n: Int)(peek: Array[Int] => Unit): Unit = {
    peek(a)
    (1 until n).foreach { i =>
      val v = a(i)
      var j = i - 1
      while (j >= 0 && a(j) > v) {
        a(j + 1) = a(j)
        j -= 1
      }
      a(j + 1) = v
      peek(a)
    }
  }
}