import Data.List
import Control.Applicative
import Control.Monad.Writer

main = do
  getLine
  input <- map read . words <$> getContents
  mapM_ putStrLn $ solve $ input

solve :: [Int] -> [String]
solve xs = let (_:ys) = snd $ runWriter (isort ([], xs)) in ys

debug :: ([Int], [Int]) -> String
debug (xs, ys) = intercalate " " $ map show (reverse xs ++ ys)

isort :: ([Int], [Int]) -> Writer [String] ([Int], [Int])
isort (xs, []) = do
  tell [debug (xs, [])]
  return (xs, [])
isort (xs, y:ys) = do
  tell [debug (xs, y:ys)]
  isort (insert' y xs, ys)

insert' :: Int -> [Int] -> [Int]
insert' x [] = [x]
insert' x (y:ys)
  | x < y = y:insert' x ys
  | otherwise = x:y:ys

