length = gets.to_i
arr = gets.split.map(&:to_i)

def selection_sort(arr, length)
  count = 0
  for i in 0..(length - 1) do
    min_idx = i
    for j in i..(length - 1) do
      if arr[j] < arr[min_idx]
        min_idx = j
      end
    end
    arr[i], arr[min_idx] = arr[min_idx], arr[i]
    if i != min_idx
      count += 1
    end
  end
  return [arr, count]
end

result, count = selection_sort(arr, length)
puts result.join(' ')
puts count
