import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val N = readInt
  val arr = readLine.split(" ").map(_.toInt)

  def selectionSort(A: Array[Int], N: Int): Int = {
    var count = 0
    for (i <- 0 until N) {
      var minJ = i
      for (j <- i until N) {
        if (A(j) < A(minJ)) minJ = j
      }
      val tmp = A(i)
      A(i) = A(minJ)
      A(minJ) = tmp
      if (i != minJ) count += 1
    }
    count
  }

  val ans = selectionSort(arr, arr.length)
  println(arr.mkString(" "))
  println(ans)
}
