import qualified Data.Char as Char import qualified Data.List as List import Data.Array import Data.Maybe import Control.Applicative import Text.Printf max_index_r xs = foldr1 f (zip xs [0..]) where f (x, xi) (m, mi) = if x > m then (x, xi) else (m, mi) iter_swap i j xs = map f (zip xs [0..]) where f (x, k) | k == i = xs !! j | k == j = xs !! i | otherwise = x main = do ns <- getLine let (ma, i) = max_index_r ns let ns' = case List.findIndex (/= ma) ns of Just j | i > j -> iter_swap i j ns _ -> ns putStrLn ns'