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) min_index_l xs = foldl1 f (zip xs [0..]) where f (m, mi) (x, xi) = 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 i = snd $ min_index_l ns let j = snd $ max_index_r ns putStrLn $ if i < j then iter_swap i j ns else ns