size = gets.to_i
array = gets.split(" ").map(&:to_i)

change_count = 0
(0..(size -1)).each do |i|
  min = i
  (i..(size-1)).each do |j|
    min = j if array[j] < array[min]
  end
  if min != i
    tmp = array[i]
    array[i] = array[min]
    array[min] = tmp
    change_count += 1
  end
end

puts array.join(" ")
puts change_count
