solve :: (Ord a) => [a] -> [[a]]
solve list = reverse answers
    where (answers,_,_) = foldl sortstep ([], 0, list) list

insert':: (Ord a) => [a] -> a -> [a]
insert' [] e = [e]
insert' list@(x:xs) e
    | e >= x = x : (insert' xs e)
    | otherwise = e : list

sortstep :: (Ord a) => ([[a]], Int, [a]) -> a -> ([[a]], Int, [a])
sortstep ([], _, list) _ = ([list], 1, list)
sortstep (current@(x:xs), n, list) e = (next:current, n+1, list)
    where next = (insert' (take n x) e) ++ (drop (n+1) list)

main = do
    n <- getLine
    strlist <- getLine >>= return . words
    let list = map read strlist :: [Int]
    mapM putStrLn $ map (unwords . map show) $ solve list

