class Array
  def swap(x, y)
    self[x], self[y] = self[y], self[x]
  end
end

def selectionSort(n, a)
  c = 0
  (n-1).times{|i|
    min = a[i+1..-1].min
    a[i]>min&&a.swap(i,a.rindex(min))&&c+=1
  }
  return a, c
end

a, c = selectionSort(gets.to_i, gets.split.map(&:to_i))
puts a.join(" ")
puts c