import           Control.Applicative
import           Control.Monad
import           Data.List           (insert, intercalate)

print' :: [Int] -> IO ()
print' xs = putStrLn $ intercalate " " $ fmap show xs

step :: [Int] -> IO ()
step (x:xs) = f [x] xs
  where
    f as []     = print' as
    f as (b:bs) = print' (as ++ (b:bs)) >> f (insert b as) bs

main :: IO ()
main = do
    getLine
    xs <- fmap read . words <$> getLine :: IO [Int]
    step xs

