object Main extends App{
    // Your code here!
    import scala.io.Source.stdin
    def sort(nums: Array[Int]): (Array[Int],Int) = {
        var times = 0
        def swap(x: Int, y: Int) {
            if(x != y) {times+=1}
            val tmp = nums(x)
            nums(x) = nums(y)
            nums(y) = tmp
        }
        for(i <- 0 until nums.length) {
            var min_index = i
            for(j <- i until nums.length) {
                min_index = if(nums(j) < nums(min_index)) j else min_index
            }
            swap(i,min_index)
        }
        (nums,times)
    }
    /*val input = {for(line <- io.Source.stdin.getLines()) yield {
        line
    }}.toSeq*/
    scala.io.StdIn.readLine
    val inputarr = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    val sorted = sort(inputarr)
    println(sorted._1.mkString(" ") + "\n" + sorted._2)
}

