fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var count = 0
    for (i in 0 until n) {
        var minj = i
        for (j in i + 1 until n) {
            if (a[j] < a[minj]) {
                minj = j
            }
        }
        if (i != minj) {
            val tmp = a[i]
            a[i] = a[minj]
            a[minj] = tmp
            count++
        }
    }

    println(a.joinToString(" "))
    println(count)
}
