import qualified Data.Vector         as V
import qualified Data.Vector.Mutable as VM
import Control.Applicative
import Control.Monad
import Data.IORef

-- 1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
-- 2   for i が 0 から N-1 まで
-- 3     minj = i
-- 4     for j が i から N-1 まで
-- 5       if A[j] < A[minj]
-- 6         minj = j
-- 7     A[i] と A[minj] を交換

selectionSort :: [Int] -> IO ([Int], Int)
selectionSort xs = do
  aVec <- V.thaw $ V.fromList xs
  let len = length xs - 1
  c <- newIORef 0
  forM_[0 .. len] $ \i -> do
    mini <- newIORef i
    forM_ [i .. len] $ \j -> do
      v1 <- VM.read aVec j
      k  <- readIORef mini
      v2 <- VM.read aVec k
      when (v1 < v2) $ writeIORef mini j
    k <- readIORef mini
    -- print (i, k)
    when (i /= k) $ do
      VM.swap aVec i k
      modifyIORef c (+ 1)
  list  <- V.toList <$> V.freeze aVec
  count <- readIORef c
  return (list, count)

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  (ys, c) <- selectionSort xs
  putStrLn $ unwords $ map show ys
  print c

