def selection_sort(array, n)
  count = 0
  0.upto(n-1) do |i|
    min_index = i
    i.upto(n-1) { |j| min_index = j if array[min_index] > array[j] }
    if min_index != i
      array[i], array[min_index] = array[min_index], array[i]
      count += 1
    end
  end
  count
end

def trace(array)
  puts array.join(' ')
end

n = $stdin.gets.chomp.to_i
array = $stdin.gets.chomp.split(' ').map(&:to_i)

count = selection_sort(array, n)
trace(array)
puts count