object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val a = io.StdIn.readLine().split(" ").map(_.toInt)
    val count = selectionSort(a, n)
    println(a.mkString(" "))
    println(count)
  }

  def selectionSort(a: Array[Int], n: Int): Int = {
    (0 until n).count { i =>
      val minIdx = (i until n).foldLeft(i) { case (z, j) =>
        if (a(j) < a(z)) j
        else z
      }
      if (i != minIdx) {
        val v = a(i)
        a(i) = a(minIdx)
        a(minIdx) = v
        true
      } else {
        false
      }
    }
  }
}