import           Control.Applicative
import           Control.Monad

sort' :: ([Int], [Int]) -> IO ([Int], [Int])
sort' (ns, []    ) = return (ns, [])
sort' (ns, o : os) = do
  let ns1 = insert' o ns
  let os1 = os
  putStrLn $ disps (ns1, os1)
  sort' (ns1, os1)

insert' :: Int -> [Int] -> [Int]
insert' n ts = h ++ [n] ++ t
 where
  h = takeWhile (<= n) ts
  t = dropWhile (<= n) ts

disps :: ([Int], [Int]) -> String
disps (ns, os) = disp ns ++ " " ++ disp os

disp :: [Int] -> String
disp xs = unwords $ map show xs

main = do
  n  <- readLn
  ts <- map (read :: String -> Int) . take n <$> fmap words getLine
  sort' ([], ts)

