import Data.Functor( (<$>))
import Data.Array.IArray
import Data.Array.Unboxed
import Data.Array.MArray( newListArray, freeze)
import Data.Array.IO
import Control.Monad

main = do
    n <- read <$> getLine
    values <- (read <$>) . words <$> getLine 
    a <- newListArray (0,n-1) values		::IO (IOUArray Int Int)
    let
	selectionScan i_
	  = do
	    let
		searchMinIx::Int -> Int -> Int -> IO Int
		searchMinIx nowMin ixNowMin iterator
		  | n <= iterator		    = return ixNowMin
		  | otherwise
		    = do
			v <- readArray a iterator
			if v < nowMin
			then searchMinIx    v	iterator (iterator+1)
			else searchMinIx nowMin ixNowMin (iterator+1)

		swap::Int -> Int -> IO ()
		swap i j = do
		    temp <- readArray a i
		    writeArray a i =<< readArray a j
		    writeArray a j temp

	    startmin <- readArray a i_
	    ixmin <- searchMinIx startmin i_ i_
	    if i_/=ixmin
	    then swap i_ ixmin >> return 1
	    else return 0
    
    selectionSortSwapCount <- sum <$> forM [0..n-1]
					    selectionScan
    ia <- freeze a  ::IO (UArray Int Int)
    putStrLn . unwords $ show <$> elems ia
    print selectionSortSwapCount


