def selection_sort(data)
  swap_count = 0
  last_index = data.size - 1
  0.upto(last_index) { |i|
    minj = i
    i.upto(last_index) { |j|
      minj = j if data[j] < data[minj]
    }
    if minj != i
      data[i], data[minj] = data[minj], data[i]
      swap_count += 1
    end
  }
  [data, swap_count]
end

data = $stdin.read.lines[1].split("\s").map(&:to_i)
sorted, swap_count = selection_sort(data)
puts sorted.join(' ')
puts swap_count