import Control.Applicative
import Control.Monad

pl :: [Int] -> IO ()
pl xs = putStrLn $ unwords $ map show xs

insertion :: Int -> [Int] -> [Int]
insertion i xs = [x | x <- p, x <= v] ++ [v] ++ [x | x <- p, v < x] ++ drop (i + 1) xs
    where
        p = take i xs
        v = xs !! i

solve :: Int -> [Int] -> [[Int]]
solve n xs = foldl (\l i -> insertion i (head l) : l) [xs] [1 .. n - 1]

main :: IO ()
main = do
    n  <- readLn
    xs <- map read <$> words <$> getLine
    mapM_ pl $ reverse $ solve n xs