-- IO バージョン

import Control.Applicative
import Data.List


solve :: ([Int], [Int]) -> IO ()
solve (as, []) = return ()
solve (as, b : bs) = do
  let cs = insert b as
  putStrLn $ unwords $ map show $ cs ++ bs
  solve (cs, bs)

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  solve ([], xs)

