import Data.IntMap ((!)) import qualified Data.IntMap as M import Data.List swap i j im = M.insert j (im!i) (M.insert i (im!j) im) main = do n <- readLn as <- map read . words <$> getLine :: IO [Int] let ias = M.fromList (zip [0..n-1] as) putStrLn $ unwords $ map show (yukisort n ias) yukisort n ias = M.elems $ foldl' ys ias [1..2*n-4] where ys acc i = foldr swappq acc [(p,q) | p<-[0 .. n-1], let q = i-p, q>0, q acc!q then swap p q acc else acc