import Control.Monad
import Data.List

main = do
    n <- read <$> getLine
    a <- forM [1 .. n] $ \_ -> do
        read <$> getLine
    forM (solve n a) $ \r -> do
        putStrLn $ show $ r

solve :: Int -> [Int] -> [Int]
solve n a = map (\a -> if a == f then s else f) a
  where
    (f : s : t) = reverse $ sort a