import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	}

	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	}

	static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	}
	static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	}

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

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	}

	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	}

	static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	}
	static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	}

} Main public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	} main {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	} int n; n Scanner sc = new Scanner(System.in); sc new Scanner(System.in) 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 print(a) print a insertionSort2(a) insertionSort2 a String[] args args static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	} print {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	} for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		} 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(" ");
			} else {
				System.out.print("\n");
			}
		} {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		} 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(" ");
			} else {
				System.out.print("\n");
			} i != a.length-1 i a.length-1 a.length a a.length 1 {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " {
				System.out.print("\n");
			} System.out.print("\n") System.out.print System.out System System.out "\n" int[] a a static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	} insertionSort1 {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	} for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		} int i = 1; int i = 1; i 1 i < a.length i a.length a a.length i++ i++ i {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		} {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		} for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			} {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			} if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				} a[i] < a[j] a[i] a i a[j] a j {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				} int tmp = a[i]; tmp a[i] a i for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					} int k = i - 1; int k = i - 1; k i - 1 i 1 k >= j k j k-- k-- k {
						a[k+1] = a[k];
					} {
						a[k+1] = a[k];
					} a[k+1] = a[k] a[k+1] a k+1 k 1 a[k] a k a[j] = tmp a[j] a j tmp print(a) print a int[] a a static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	} insertionSort2 {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	} for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		} int i = 1; int i = 1; i 1 i < a.length i a.length a a.length i++ i++ i {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		} {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		} int v = a[i]; v a[i] a i int j = i-1; j i-1 i 1 while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			} j >= 0 && a[j] > v j >= 0 j 0 a[j] > v a[j] a j v {
				a[j+1] = a[j];
				j--;
			} a[j+1] = a[j] a[j+1] a j+1 j 1 a[j] a j j-- j a[j+1] = v a[j+1] a j+1 j 1 v print(a) print a int[] a a public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	}

	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	}

	static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	}
	static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	}

} public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	}

	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	}

	static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	}
	static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		print(a);
		insertionSort2(a);

	}

	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			} else {
				System.out.print("\n");
			}
		}
	}

	static void insertionSort1(int[] a) {
		for (int i = 1; i < a.length; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int tmp = a[i];
					for (int k = i - 1; k >= j; k--) {
						a[k+1] = a[k];
					}
					a[j] = tmp;
				}
			}
			print(a);
		}
	}
	static void insertionSort2(int[] a) {
		for (int i = 1; i < a.length; i++) {
			int v = a[i];
			int j = i-1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print(a);
		}
	}

}
