def selectionSort a, n 
    count = 0
    for i in 0 .. n - 2
        minj = i;
        for j in i + 1 .. n - 1
            minj = j if a[j] < a[minj]
        end
        if i != minj
            temp = a[i]
            a[i] = a[minj]
            a[minj] = temp
            count += 1
        end
    end
    return count
end

n = gets.to_i
arr = gets.chomp.split.map(&:to_i)
count = selectionSort(arr, n);
puts arr.join(" ")
puts count