{-
SelectionSort(A)
1 for i = 0 to A.length-1
2     mini = i
3     for j = i to A.length-1
4         if A[j] < A[mini]
5             mini = j
6     swap A[i] and A[mini]
-}

main = do 
    s1 <- getLine
    s2 <- getLine
    let a = map (\x -> read x :: Int) $ words s2
    let (swapCount, sorteda) = ssorti (0,a) 0
    putStrLn $ unwords $ map show sorteda
    putStrLn $ show swapCount

ssorti :: (Int,[Int]) -> Int -> (Int,[Int])
ssorti (swapCount, a) i
  | i <= length a - 1 = ssorti (ssortj (swapCount, a) i i i) (i+1)
  | otherwise         = (swapCount, a)

ssortj :: (Int,[Int]) -> Int -> Int -> Int -> (Int,[Int])
ssortj (swapCount, a) i j mini
  | j <= length a - 1 && a!!j < a!!mini = ssortj (swapCount, a) i (j+1) j
  | j <= length a - 1                   = ssortj (swapCount, a) i (j+1) mini
  | a!!i /= a!!mini                     = (swapCount+1, swap a i mini)
  | otherwise                           = (swapCount, a)

swap :: [Int] -> Int -> Int -> [Int]
swap a i j = (take i1 a) ++ [a!!i2] ++ (take (i2-i1-1) $ drop (i1+1) a) ++ [a!!i1] ++ (drop (i2+1) a)
  where (i1, i2) = (min i j, max i j)
