let print_array l =
  Array.fold_left (fun x y -> (if x = "" then "" else x^" ")^(string_of_int y)) "" l
  |> print_endline;;
let to_array s = Str.split (Str.regexp_string " ") s
                 |> List.map (fun x -> int_of_string x)
                 |> Array.of_list;;

let sort a =
  let rec loop ct = function
      i when i = Array.length a -> print_array a;string_of_int ct |> print_endline
    | i ->
       let mini = i in
       let rec loop2 m = function
           j when j = Array.length a -> m
         | j -> if a.(j) < a.(m) then loop2 j (j+1) else loop2 m (j+1)
       in
       let swap_mini = loop2 mini i in
       let swap_ct = if swap_mini != i then ct+1 else ct in
       let temp = a.(i) in
       a.(i) <- a.(swap_mini);
       a.(swap_mini) <- temp;
       loop swap_ct (i+1)
  in
  loop 0 0;;

let _ =
  let _ = read_int () and
      a = read_line () |> to_array
  in sort a;;