input = []
while (n = gets.to_i) != 0 do
  input = gets.split.map(&:to_i)
end
n = input.size
count = 0

for i in 0..n-1 do
  min_j = i
  for j in i..n-1 do
    min_j = j if input[j] < input[min_j]
  end
  break if input[min_j] == input[i]

  tmp = input[min_j]
  input[min_j] = input[i]
  input[i] = tmp
  count += 1
end

puts input*" "
puts count
