length = gets.to_i
arr = gets.split(" ").map(&:to_i)
change_count = 0

length.times do |index|
    minimum_index = index
    (index..(length - 1)).each do |search_index|
        minimum_index = search_index if arr[minimum_index] > arr[search_index]
    end
    if minimum_index != index
        tmp = arr[minimum_index]
        arr[minimum_index] = arr[index]
        arr[index] = tmp
        change_count += 1
    end
end

puts arr.join(" ")
puts change_count

