import java.io.*;

class Main{
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        private static void printArray(int[] A){
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        }

        private static int selectionSort(int[] A){
                int count = 0;
                int mini = 0;

                for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                }
                return count;
        }
        public static void main(String[] args) throws IOException{
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];

                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);

                int count = selectionSort(A);

                printArray(A);
                System.out.println(count);
        }
} import java.io.*; io.* java class Main{
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        private static void printArray(int[] A){
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        }

        private static int selectionSort(int[] A){
                int count = 0;
                int mini = 0;

                for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                }
                return count;
        }
        public static void main(String[] args) throws IOException{
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];

                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);

                int count = selectionSort(A);

                printArray(A);
                System.out.println(count);
        }
} Main private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) private static void swap(int[] A, int i, int j){
                int tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
        } swap {
                int tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
        } int tmp = A[i]; tmp A[i] A i A[i] = A[j] A[i] A i A[j] A j A[j] = tmp A[j] A j tmp int[] A A int i i int j j private static void printArray(int[] A){
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        } printArray {
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        } for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                } int i=0; int i=0; i 0 i<A.length i A.length A A.length i++ i++ i {
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                } {
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                } System.out.print(A[i]) System.out.print System.out System System.out A[i] A i if(i!=A.length-1)
                                System.out.print(" "); i!=A.length-1 i A.length-1 A.length A A.length 1 System.out.print(" ") System.out.print System.out System System.out " " System.out.println() System.out.println System.out System System.out int[] A A private static int selectionSort(int[] A){
                int count = 0;
                int mini = 0;

                for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                }
                return count;
        } selectionSort {
                int count = 0;
                int mini = 0;

                for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                }
                return count;
        } int count = 0; count 0 int mini = 0; mini 0 for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                } int i=0; int i=0; i 0 i<A.length-1 i A.length-1 A.length A A.length 1 i++ i++ i {
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                } {
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                } boolean doswap = false; doswap false mini = i mini i for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                } int j=i+1; int j=i+1; j i+1 i 1 j<A.length j A.length A A.length j++ j++ j if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                } if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                } A[j] < A[mini] A[j] A j A[mini] A mini {
                                        mini = j;
                                        doswap = true;
                                } mini = j mini j doswap = true doswap true if(doswap){
                                swap(A, i, mini);
                                count++;
                        } doswap {
                                swap(A, i, mini);
                                count++;
                        } swap(A, i, mini) swap A i mini count++ count return count; count int[] A A public static void main(String[] args) throws IOException{
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];

                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);

                int count = selectionSort(A);

                printArray(A);
                System.out.println(count);
        } main {
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];

                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);

                int count = selectionSort(A);

                printArray(A);
                System.out.println(count);
        } int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String[] iline = br.readLine().split(" "); iline br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] A = new int[N]; A new int[N] N for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]); int i=0; int i=0; i 0 i<N i N i++ i++ i A[i] = Integer.parseInt(iline[i]); A[i] = Integer.parseInt(iline[i]) A[i] A i Integer.parseInt(iline[i]) Integer.parseInt Integer iline[i] iline i int count = selectionSort(A); count selectionSort(A) selectionSort A printArray(A) printArray A System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;

class Main{
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        private static void printArray(int[] A){
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        }

        private static int selectionSort(int[] A){
                int count = 0;
                int mini = 0;

                for(int i=0; i<A.length-1; i++){
                        boolean doswap = false;
                        mini = i;
                        for(int j=i+1; j<A.length; j++)
                                if(A[j] < A[mini]){
                                        mini = j;
                                        doswap = true;
                                }
                        if(doswap){
                                swap(A, i, mini);
                                count++;
                        }
                }
                return count;
        }
        public static void main(String[] args) throws IOException{
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];

                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);

                int count = selectionSort(A);

                printArray(A);
                System.out.println(count);
        }
}