object InsertionSort extends App {
  def insertionSort(x: Int, list: List[Int]): List[Int] = list match {
    case Nil =>
      List(x)
    case (y :: ys) =>
      if (x < y) x :: y :: ys else y :: insertionSort(x, ys)
  }

  val num: Int = io.StdIn.readLine().toInt
  var unsorted: List[Int] = scala.io.StdIn.readLine().split(" ").toList.map(_.toInt)
  var sorted: List[Int] = List()
  for (i <- 0 to (num - 1)) {
    val x = unsorted.head
    unsorted = unsorted.tail
    sorted = insertionSort(x, sorted)
    println(sorted.mkString(" ") + " " + unsorted.mkString(" "))
  }
}