import Control.Monad
import Control.Applicative

main = do
  _ <- getLine
  nums <- words <$> getLine
  let index = [0 .. (length nums)]
  forLike (length nums - 1) nums $ \n ns -> do
    let sorted = instSort n ns
    putStrLn . unwords $ sorted
    return sorted

forLike :: Int -> b -> (Int -> b -> IO b) -> IO ()
forLike 0 _ _ = return ()
forLike n e f = do
   res <- f n e
   forLike (n - 1) res f

instSort :: Ord a => Int -> [a] -> [a]
instSort n xs
  |n >= len  = []
  |otherwise = (insert (>=) sorted y) ++ ys
  where len = length xs
        (sorted, (y:ys)) = splitAt n xs

insert :: (a -> a -> Bool) -> [a] -> a -> [a]
insert _ [] y = [y]
insert f (x:xs) y
  | f x y     = y : x : xs
  | otherwise = x : insert f xs y