var cnt:Int=0

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    selectionSort(list.toIntArray(),n)
}
fun selectionSort(A:IntArray, N:Int) {
    var tmp:Int
    for (i in (0..(N - 1))) {
        var minj :Int= i
        for (j in (i .. (N - 1)))
        {
            if (A[j] < A[minj])
            {
                minj = j
            }
        }
        if (A[minj] != A[i])
        {
            tmp = A[minj]
            A[minj] = A[i]
            A[i] =tmp
            cnt++
        }
    }
    println(A.joinToString(" "))
    println(cnt)
}
