fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map(String::toInt).toMutableList()

  var cnt = 0
  (0 until N).forEach { i ->
    var minX = i
    (i until N).forEach { j ->
      if (A[j] < A[minX]) {
        minX = j
      }
    }
    if (A[i] != A[minX]) {
      val tmp = A[i]
      A[i] = A[minX]
      A[minX] = tmp
      cnt += 1
    }
  }
  println(A.joinToString((" ")))
  println(cnt)
}
