
import scala.io.StdIn

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

    trace(array)
    insertionSort(array)
  }

  def insertionSort(array: Array[Int]): Unit = {
    val length = array.length
    for (i <- 1 to length - 1) {
      val v = array(i)
      var j = i - 1
      while (j >= 0 && array(j) > v) {
        array(j + 1) = array(j)
        j -= 1
      }
      array(j + 1) = v
      trace(array)
    }
  }

  def trace(array: Array[Int]): Unit = {
    val result = for (i <- array.toList) yield i
    println(result.mkString(" "))
  }
}