def selection_sort
  @N.times do |i|
    minj = i
    i.upto (@N-1) do |j|
      minj = j  if @A[j] < @A[minj]
    end
    if @A[i] != @A[minj]
      @A[i], @A[minj] = @A[minj], @A[i]
      @count += 1
    end
  end
end



@count = 0
@N = gets.to_i
@A = gets.split(" ").map{|x| x.to_i}

selection_sort

@A.each_with_index do |x, i|
  print x
  print i == @N-1 ? "\n" : " "
end
puts @count

