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();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

} 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();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

} 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();
		}
		Print(A, n);
		Sort(A, n);
		
	} 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();
		}
		Print(A, n);
		Sort(A, n);
		
	} 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] = scan.nextInt() A[i] A i scan.nextInt() scan.nextInt scan Print(A, n) Print A n Sort(A, n) Sort A n String args[] args public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	} Print {
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	} 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 int A[] A int n n public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	} Sort {
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	} int v = 0; v 0 int j = 0; j 0 for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		} {
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		} v = A[i] v A[i] A i 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,n) Print A n int A[] A int n n 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();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

} 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();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

} 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();
		}
		Print(A, n);
		Sort(A, n);
		
	}
	
	public static void Print(int A[], int n){
		for(int i = 0; i < n; i++){
			if(i > 0){
				System.out.print(" ");
				
			}
			System.out.print(A[i]);
		}
		System.out.println();
	}
	
	public static void Sort(int A[], int n){
		int v = 0;
		int j = 0;
		for(int i = 1; i < n; i++){
			v = A[i];
			j = i -1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			Print(A,n);
		}
	}

}