import Data.Functor( (<$>))

main = do
    n <- read <$> getLine
    problem <- (read <$>) . words <$> getLine	::IO [Int]
    let
	merge [] x = [x]
	merge list@(a:as) x
	    | x<=a	= x:list
	    | otherwise	= a:merge as x

	step result@(list, [])  = result
	step (list1, e:es) = (merge list1 e, es)

	display (list1, list2) = putListLn $ list1++list2
	  where
	    putListLn = putStrLn . unwords . (show <$>)

    display `mapM_` (take n . tail $ iterate step ([],problem))

