size = gets.chomp.to_i
input_values = gets.chomp.split.map(&:to_i)

count = 0
min_index = 0
  (0..size-1).each do |i|
    min_index = i
    (i..size-1).each do |j|
      if input_values[j] < input_values[min_index]
        min_index = j
      end
    end

    if input_values[min_index] < input_values[i]
      tmp = input_values[i]
      input_values[i] = input_values[min_index]
      input_values[min_index] = tmp
      count += 1
    end
  end
  puts input_values.join(' ')
  puts count