import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    sSort(List(), line, 0)
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int){
    if((sorted ::: unsorted).length == 1)
      println(unsorted.mkString(" ") + "\n" + (n+1))
    else if(unsorted.length == 1)
      println((sorted ::: unsorted).mkString(" ") + "\n" + n)
    else if(unsorted.sorted == unsorted)
      println((sorted ::: unsorted).mkString(" ") + "\n" + n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0)
      sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      // pos??¨head???????´????swap?????????
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}