let cnt = ref 0

let selection_sort a n =
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t in
  for i = 0 to n - 1 do
    let mini = ref i in
    for j = i to n - 1 do
      if a.(j) < a.(!mini) then mini := j;
    done;
    if !mini <> i then begin
      swap i !mini;
      incr cnt;
    end;
  done

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;
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ();
  Printf.printf "%d\n" !cnt