loop do
  n = gets.to_i
  break if n == 0
  arr = gets.split(' ').map(&:to_i)

  count = 0
  0.upto(n-1) do |i|
    min_idx = i
    (i+1).upto(n-1) do |j|
      min_idx = j if arr[min_idx] > arr[j]
    end

    if min_idx != i
      count += 1
      arr[i], arr[min_idx] = arr[min_idx], arr[i]
    end
  end

  puts arr.join(' ')
  puts count
end