let cnt = ref 0

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 swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  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 begin
      let minj = select i i in
      if minj <> i then (swap i minj; incr cnt);
      doit (i + 1)
    end
  in
  doit 0

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