module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Int] -> [[Int]]
solve = iter [] where
    iter al []        = [al]
    iter [] xl@(x:xs) = iter [x] xs
    iter al xl@(x:xs) =(al++xl):iter (insertX x al) xs where
        insertX x [] = [x]
        insertX x al@(a:as)
            | a > x = x:al
            | otherwise = a:insertX x as
 
readLine:: IO [Int]
readLine = fmap (map read . words) getLine

main :: IO() 
main = do
    n <- readLn :: IO Int
    l <- readLine
    mapM_ putStrLn $ map (\y -> init (concatMap (\x-> show x ++ " ") y)) (solve l)

