import scala.annotation.tailrec
import scala.io.Source

object Main extends App {
  val lines = Source.stdin.getLines()
  val n = lines.next().toInt
  val list = lines.next.split(" ")
  val realList = list.toList
  solve(realList)


  def solve(list: List[String]): List[Int] = {
    list.map(_.toInt).foldLeft(List[Int]())((x, y) => {
      val sorted = insert(x, y)
      println((sorted ::: realList.drop(sorted.size)).mkString(" "))
      sorted
    })
  }

  def insert(list: List[Int], x: Int): List[Int] = list match {
    case Nil => List(x)
    case y :: ys => if (y > x) x :: y :: ys else y :: insert(ys, x)
  }
}
