import Control.Applicative

f :: [Int] -> [Int]
f [x] = [x]
f (x:y:z)
    | x < y = y : f (x:z)
    | otherwise = x : f (y:z)

g [] = []
g xs = y : g ys
  where (y:ys) = reverse $ f xs 

main :: IO ()
main = do
  s <- map read . words <$> getLine
  putStrLn $ unwords $ map show (g s)
