import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	}

	private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	}

	private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	}

	private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	}

	private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	}

	private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	}

	private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	} main {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
			a[i] = scan.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = scan.nextInt(); a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan runSel(a) runSel a scan.close() scan.close scan System.exit(0) System.exit System 0 String[] args args private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	} runSel {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	} int op = 0; op 0 for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		} {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		} int min = i; min i for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j; int j = i; int j = i; j i j < a.length j a.length a a.length j++ j++ j if (a[j] < a[min])
					min = j; if (a[j] < a[min])
					min = j; a[j] < a[min] a[j] a j a[min] a min min = j min j if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			} min != i min i {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			} int tmp = a[i]; tmp a[i] a i a[i] = a[min] a[i] a i a[min] a min a[min] = tmp a[min] a min tmp op++ op outResult(a, op) outResult a op int[] a a private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	} run {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	} int op = 0; op 0 for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} int j = a.length - 1; int j = a.length - 1; j a.length - 1 a.length a a.length 1 j > i j i j-- j-- j if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} a[j] < a[j - 1] a[j] a j a[j - 1] a j - 1 j 1 {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				} int tmp = a[j]; tmp a[j] a j a[j] = a[j - 1] a[j] a j a[j - 1] a j - 1 j 1 a[j - 1] = tmp a[j - 1] a j - 1 j 1 tmp op++ op outResult(a, op) outResult a op int[] a a private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	} outResult {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	} for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]); int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]); if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]); i == 0 i 0 System.out.print(a[i]) System.out.print System.out System System.out a[i] a i System.out.print(" " + a[i]) System.out.print System.out System System.out " " + a[i] " " a[i] a i System.out.println() System.out.println System.out System System.out System.out.println(op) System.out.println System.out System System.out op int[] a a int op op public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	}

	private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	}

	private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	}

	private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	}

	private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	}

	private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	}

	private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		// run(a);
		runSel(a);

		scan.close();
		System.exit(0);
	}

	private static void runSel(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++) {
			int min = i;
			for (int j = i; j < a.length; j++)
				if (a[j] < a[min])
					min = j;
			if (min != i) {
				int tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
				op++;
			}
		}

		outResult(a, op);

	}

	private static void run(int[] a) {
		int op = 0;
		for (int i = 0; i < a.length; i++)
			for (int j = a.length - 1; j > i; j--)
				if (a[j] < a[j - 1]) {
					int tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					op++;
				}

		outResult(a, op);
	}

	private static void outResult(int[] a, int op) {
		for (int i = 0; i < a.length; i++)
			if (i == 0)
				System.out.print(a[i]);
			else
				System.out.print(" " + a[i]);
		System.out.println();
		System.out.println(op);

	}

}