import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
} Main public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	} BubbleSort {
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	} int count = 0; count 0 for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		} {
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		} int min = A[i]; min A[i] A i int min_pos = i; min_pos i for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			} int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			} {
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			} if(A[j] < min){
					min = A[j];
					min_pos = j;
				} A[j] < min A[j] A j min {
					min = A[j];
					min_pos = j;
				} min = A[j] min A[j] A j min_pos = j min_pos j if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			} min_pos != i min_pos i {
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			} int tmp = A[i]; tmp A[i] A i A[i] = min A[i] A i min A[min_pos] = tmp A[min_pos] A min_pos tmp count++ count return count; count final int N N int[] A A public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	} main {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N]; A new int[N] N for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			A[i] = sc.nextInt();
		} {
			A[i] = sc.nextInt();
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc final int times = BubbleSort(N, A); times BubbleSort(N, A) BubbleSort N A for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		} {
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		} if(i != 0){
				System.out.print(" ");
			} i != 0 i 0 {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " System.out.print(A[i]) System.out.print System.out System System.out A[i] A i System.out.println() System.out.println System.out System System.out System.out.println(times) System.out.println System.out System System.out times String args[] args public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
} public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
}