object Main {
  // NOTE: Destructive: arr
  def printInsertSort(arr: Array[Int]): Unit= {
    for (i <- (1 until arr.length)) {
      // Print arr
      println(arr.mkString(" "))
      val v = arr(i)
      var j = i - 1
      while(j >= 0 && arr(j) > v) {
        arr(j+1) = arr(j)
        j -= 1
      }
      arr(j+1) = v
    }
    // Print arr
    println(arr.mkString(" "))
  }

  def main(args: Array[String]): Unit = {
    // Skip n
    io.StdIn.readLine()

    // Read arry string
    var arrString: String = io.StdIn.readLine()
    // Convert it to real int array
    val arr: Array[Int] = arrString.split(" ").map(_.toInt)

    // Print insert sort step
    printInsertSort(arr)
  }
}
