object Main extends App {
  val N               = readInt
  val list: List[Int] = readLine.split(" ").map(_.toInt).toList

  (1 to N).foldLeft(list)((acc, h) => sortAndPrint(acc, h - 1))

  def sortAndPrint(list: List[Int], i: Int): List[Int] = {
    val target = list(i)
    val insertIndex = list.take(i).dropWhileRight(target <= _).length
    val newList = list.take(insertIndex) ++ List(target) ++ list.filter(_ != target).drop(insertIndex)
    println(newList.mkString(" "))
    newList
  }

  implicit class RichList[A](l: List[A]) {
    def dropWhileRight(f: A => Boolean): List[A] = {
      l.reverse.dropWhile(f).reverse
    }
  }
}
