import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Array.MArray
import           Data.Array.ST
import           Data.STRef

print' :: Show a => [a] -> IO ()
print' = putStrLn . unwords . fmap show

selection :: [Int] -> ([Int], Int)
selection xs =
    runST $ do
        let n = length xs
        countRef <- newSTRef 0

        minjRef <- newSTRef 0
        a <- newListArray (0, length xs - 1) xs :: ST s (STUArray s Int Int)

        forM_ [0 .. n - 1] $ \i -> do
            writeSTRef minjRef i
            forM_ [i .. n - 1] $ \j -> do
                p <- readArray a j
                q <- readArray a =<< readSTRef minjRef
                when (p < q) $ writeSTRef minjRef j
            k <- readSTRef minjRef
            temp1 <- readArray a i
            temp2 <- readArray a k
            when (temp1 /= temp2) $ do
                writeArray a i temp2
                writeArray a k temp1
                modifySTRef' countRef (+ 1)

        c <- readSTRef countRef
        es <- getElems a
        return (es, c)

main :: IO ()
main = do
    getLine
    xs <- fmap read . words <$> getLine :: IO [Int]
    let (as, b) = selection xs
    print' as
    print b

