--選択ソート

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

import Data.List
--bounds,array,未ソート開始インデックス、Actionと交換の有無
select_ins::(Int,Int) -> STArray s Int Int -> Int -> ST s Bool
select_ins (s,e) ar idx = if idx == e then return False else do
  (min_id,min_v)<-find_min ar (idx,e)
  h<-readArray ar idx
  writeArray ar idx min_v
  writeArray ar min_id h
  return (min_id/=idx)

--アレイ、探索範囲、インデックスリターン
find_min::STArray s Int Int -> (Int,Int) -> ST s (Int,Int)
find_min ar (s,e) = do
  iar<-freeze ar
  return (minimumBy (\ (i_x,x) -> \ (i_y,y) -> compare x y ) (filter (\(i,v)-> i<=e&&i>=s) (assocs iar)))

sel_sort::Array Int Int ->(Int,Array Int Int)
sel_sort ar = runST $ do
  let (s,e) =  bounds ar
  mar<-thaw ar
  bs<-forM [s..e-1] (select_ins (s,e) mar)
  iar<-freeze mar
  return (length (filter id bs),iar)

main::IO()
main=do
  nc<-getLine
  let n = read nc
  d<-getLine
  let ar = listArray (1,n) (map read (words d))
  let (c,out) = sel_sort ar
  putStr ((ls_show (elems out))++"\n")
  print c

ls_show::[Int]->String
ls_show [] = []
ls_show (x:xs) = (show x)++(if xs == [] then (ls_show xs) else ' ':(ls_show xs))
