let cnt = ref 0

let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> List.rev (s :: acc)
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let selection_sort a n =
  let rec select j minj =
    if j >= n then minj
    else select (j + 1) (if a.(j) < a.(minj) then j else minj)
  in
  let rec doit i =
    if i >= n then ()
    else begin
      let minj = select i i in
      if minj <> i then begin
        let tmp = a.(i) in a.(i) <- a.(minj); a.(minj) <- tmp;
        incr cnt
      end;
      doit (i + 1)
    end
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (split (read_line ()) ' ')) in
  selection_sort a n;
  print_array a;
  Printf.printf "%d\n" !cnt