import scala.io.StdIn._

object Main extends App {

  def selectionSort(a: Array[Int], n: Int) {
    var cnt = 0
    for (i <- (0 until n-1)) {
      val tmp_a = a.takeRight(n - i)
      val min_v_index = tmp_a.indexOf(tmp_a.min) + i
      val tmp_v = a(i)
      a(i) = a(min_v_index)
      a(min_v_index) = tmp_v
      if (i != min_v_index) cnt += 1
    }
    println(a.mkString(" "))
    println(cnt)
  }

  val n: Int = readLine.toInt
  val a: Array[Int] = readLine.split(" ")
                              .map(s => s.toInt)
                              .toArray
  selectionSort(a, n)
}
