# 3_4_selectionsort
# ALDS_1_2_B: Selection Sort
N = gets.to_i
a = gets.split.map(&:to_i)
# N = 6
# a = [5,6,4,2,1,3]

def selection_sort(n,a)
  count = 0
  a.each_with_index do |val,i|

    min_j = i
    i.upto(n-1) do |j|
      min_j = j if a[j] < a[min_j]
    end
    a[i],a[min_j] = a[min_j],a[i]
    count += 1
  end
  puts a.join(' ')
  puts count
end
selection_sort(N,a)

