def f
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  selection_sort(a, n)
end

def selection_sort(a,n)
  exchange_counts = 0
  for i in 0..n-1
    minj = i
    for j in i..n-1
      if a[j] < a[minj]
        minj = j
      end
    end
    if i != minj
      a[i], a[minj] = a[minj], a[i]
      exchange_counts += 1
    end
  end
  puts a.join(" ")
  puts exchange_counts
end

f
