import java.util.Scanner;

public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            }

 import java.util.Scanner; Scanner java.util public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            } Main static int  cnt =0; cnt 0 public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        } selectSort {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        } if (arr == null || arr.length < 2){
                return;
            } arr == null || arr.length < 2 arr == null arr null arr.length < 2 arr.length arr arr.length 2 {
                return;
            } return; for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            } {
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            } int minIdex = i; minIdex i for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                } int j = i; int j = i; j i j < arr.length j arr.length arr arr.length j++ j++ j {
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                } {
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                } minIdex = arr[minIdex] > arr[j] ? j : minIdex minIdex arr[minIdex] > arr[j] ? j : minIdex arr[minIdex] > arr[j] arr[minIdex] arr minIdex arr[j] arr j j minIdex swap(arr,i,minIdex) swap arr i minIdex if (i != minIdex){
                    cnt++;
                } i != minIdex i minIdex {
                    cnt++;
                } cnt++ cnt int arr[] arr public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        } swap {
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        } int tmp = arr[i]; tmp arr[i] arr i arr[i] = arr[j] arr[i] arr i arr[j] arr j arr[j] = tmp arr[j] arr j tmp int arr[] arr int i i int j j public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        } printArray {
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        } System.out.print(arr[0]) System.out.print System.out System System.out arr[0] arr 0 for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            } int i = 1; int i = 1; i 1 i < arr.length i arr.length arr arr.length i++ i++ i {
                System.out.print(" " + arr[i]);
            } {
                System.out.print(" " + arr[i]);
            } System.out.print(" " + arr[i]) System.out.print System.out System System.out " " + arr[i] " " arr[i] arr i System.out.println() System.out.println System.out System System.out int []arr arr public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                } main {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int[] arr = new int[N]; arr new int[N] N for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
                        arr[i] = in.nextInt();
                    } {
                        arr[i] = in.nextInt();
                    } arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in selectSort(arr) selectSort arr printArray(arr) printArray arr System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            } public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            } Main
import java.util.Scanner;

public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            }


