n = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)

change_count = 0
n.times do |nn|
  s = n - 1 - nn
  nm = nn + 1
  min = nums[nn]
  hoge = -111
  s.times do
    if min > nums[nm]
      hoge = nm
      min = nums[nm]
    end
    nm += 1
  end
  #入れ替え作業
  if hoge > 0
    tmp = nums[nn]
    nums[nn] = nums[hoge]
    nums[hoge] = tmp
    change_count += 1
  end
end

puts nums.join(" ")
puts change_count
