n = gets.chomp.to_i
list = gets.chomp.split(' ').map(&:to_i)

def selection_sort(list)
  cnt = 0
  (0..(list.length - 1)).each do |i|
    minj = i
    (i..(list.length - 1)).each do |j|
      if list[j] < list[minj]
        minj = j
      end
    end
    cnt += 1 if i != minj
    v1 = list[i]
    v2 = list[minj]
    list[i] = v2
    list[minj] = v1
  end

  return list, cnt
end

list, cnt = selection_sort(list)
puts list.join(' ')
puts cnt

