class Array
  def selection_sort
    data = self
    n = data.size
    cnt = 0
    0.upto(n - 2) do |i|
      min = i
      (i + 1).upto(n - 1) do |j|
        if data[j] < data[min]
          min = j
        end
      end
      if i != min
        tmp = data[i]
        data[i] = data[min]
        data[min] = tmp
        cnt += 1
      end
    end
    return [data, cnt]
  end
end

n = gets.to_i
nums = gets.chomp.split(" ").map(&:to_i)
sorted_nums, cnt = nums.selection_sort
puts "#{sorted_nums.join(" ")}\n#{cnt}"