import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	}
} Main public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	} main {
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	} Scanner x=new Scanner (System.in); x new Scanner (System.in) int a=x.nextInt(); a x.nextInt() x.nextInt x int a1[]=new int [a]; a1 new int [a] a for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		} int i=0; int i=0; i 0 i<a i a i++ i++ i {
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		} {
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		} a1[i]=x.nextInt() a1[i] a1 i x.nextInt() x.nextInt x System.out.print(a1[i]) System.out.print System.out System System.out a1[i] a1 i if(i<a1.length-1)
				System.out.print(" "); i<a1.length-1 i a1.length-1 a1.length a1 a1.length 1 System.out.print(" ") System.out.print System.out System System.out " " System.out.println() System.out.println System.out System System.out for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		} int i=1; int i=1; i 1 i<a1.length i a1.length a1 a1.length i++ i++ i {
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		} {
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		} int key=a1[i]; key a1[i] a1 i int j=i-1; j i-1 i 1 while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			} j>=0&&a1[j]>key j>=0 j 0 a1[j]>key a1[j] a1 j key {
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			} a1[j+1]=a1[j] a1[j+1] a1 j+1 j 1 a1[j] a1 j j-- j a1[j+1]=key a1[j+1] a1 j+1 j 1 key int d=0; d 0 for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			} int w=0; int w=0; w 0 w<a1.length w a1.length a1 a1.length w++ w++ w {
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			} {
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			} System.out.print(a1[w]) System.out.print System.out System System.out a1[w] a1 w if(d>=0&&d<a1.length-1)
					System.out.print(" "); d>=0&&d<a1.length-1 d>=0 d 0 d<a1.length-1 d a1.length-1 a1.length a1 a1.length 1 System.out.print(" ") System.out.print System.out System System.out " " d++ d if(d==a){
					System.out.println();
					d=0;
				} d==a d a {
					System.out.println();
					d=0;
				} System.out.println() System.out.println System.out System System.out d=0 d 0 String args[] args public class Main{
	public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	}
} public class Main{
	public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	}
} Main
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner x=new Scanner (System.in);
		int a=x.nextInt();
		int a1[]=new int [a];
		for(int i=0;i<a;i++){
			a1[i]=x.nextInt();
			System.out.print(a1[i]);
			if(i<a1.length-1)
				System.out.print(" ");
		}
		System.out.println();
		for(int i=1;i<a1.length;i++){
			int key=a1[i];
			int j=i-1;
			while(j>=0&&a1[j]>key){
				a1[j+1]=a1[j];
				j--;
				a1[j+1]=key;
			}
			int d=0;
			for(int w=0;w<a1.length;w++){
				System.out.print(a1[w]);
				if(d>=0&&d<a1.length-1)
					System.out.print(" ");
				d++;
				if(d==a){
					System.out.println();
					d=0;
				}
			}
		}
	}
}
