{-# LANGUAGE FlexibleContexts #-}
import qualified Data.Array.MArray as MA
import Control.Monad
import Data.Ix
import Data.Array.IO

main::IO ()
main=do
  n <- read <$> getLine::IO Int
  let aryRange= (1,n)
  numList <- map read . words <$> getLine::IO [Int]
  ary <- MA.newListArray aryRange numList::IO (IOUArray Int Int)
  mapM_
    (\x->
      do
        insert aryRange x ary
        output <- unwords . map show <$> MA.getElems ary
        putStrLn output
    )
    [1..n]


change::(MA.MArray a e m, Ix i)=>i->i->a i e->m ()
change a b ary=do
  va <- MA.readArray ary a
  vb <- MA.readArray ary b
  MA.writeArray ary a vb
  MA.writeArray ary b va

insertSort::MA.MArray a Int m=>a Int Int ->m ()
insertSort ary=
  do
    (minI,maxI) <- MA.getBounds ary
    mapM_ (\n->insert (minI,maxI) n ary) [2..maxI]

insert::MA.MArray a Int m=>(Int,Int)->Int->a Int Int->m ()
insert (minI,maxI) begin ary=
  if begin > minI
    then
      do
        let back=begin-1
        forward<- MA.readArray ary back
        next<- MA.readArray ary begin
        when (forward > next)
          $ do
            change back begin ary
            when (minI < back) (insert (minI,maxI) back ary)
    else
      return ()