import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {

    // Complete the insertionSort1 function below.
    
    static void print(int[] arr){
        for(int i=0;i<arr.length;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.println(" ");
    }
    
    static void insertionSort1(int n, int[] arr) {
        int k=0;
        int a=0;
        for(int i=n-2;i>=0;i--){
            a = arr[i];
            for(int j=i-1;j>=0;j--){
                if(arr[j]<a){
                    k = j;
                    //break;
                    for(int b=i-1; b>k;b--){
                        //int t=arr[b+1];
                        arr[b+1]=arr[b];
                        //arr[b+2]=t;
                    }
                    print(arr);
                    break;
                }
            }
            //arr[k]=arr[i];
            
            arr[k]=a;
        }
        
        print(arr);
    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        int[] arr = new int[n];

        String[] arrItems = scanner.nextLine().split(" ");
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        for (int i = 0; i < n; i++) {
            int arrItem = Integer.parseInt(arrItems[i]);
            arr[i] = arrItem;
        }

        insertionSort1(n, arr);

        scanner.close();
    }
}

@@ -471,27 +471,20 @@
 nt k
-=0;%0A        int a=0
+ey= arr%5Bn-1%5D
 ;%0A  
@@ -506,17 +506,18 @@
 =n-2;i%3E=
-0
+-1
 ;i--)%7B%0A 
@@ -531,54 +531,16 @@
     
-a = arr%5Bi%5D;%0A            for(int j=i-1;j%3E=0;j--
+if(i==-1
 )%7B%0A 
@@ -558,47 +558,18 @@
     
-if(
 arr%5B
-j%5D%3Ca)%7B%0A                    k = j
+0%5D=key
 ;%0A  
@@ -586,19 +586,18 @@
     
-    //break
+print(arr)
 ;%0A  
@@ -614,36 +614,14 @@
     
-    for(int b=i-1; b%3Ek;b--)%7B
+break;
 %0A   
@@ -621,32 +621,34 @@
 ak;%0A            
+%7D%0A
             //in
@@ -647,34 +647,24 @@
     
-//int t=arr%5Bb+1%5D;%0A        
+if(arr%5Bi%5D%3Ekey)%7B%0A
     
@@ -683,17 +683,17 @@
 arr%5B
-b
+i
 +1%5D=arr%5B
 b%5D;%0A
@@ -688,17 +688,17 @@
 +1%5D=arr%5B
-b
+i
 %5D;%0A     
@@ -712,35 +712,20 @@
     
-        //arr%5Bb+2%5D=t;%0A     
+print(arr);%0A
     
@@ -724,35 +724,32 @@
 r);%0A            
-   
 %7D%0A              
@@ -746,35 +746,21 @@
         
-        print(arr);
+else%7B
 %0A       
@@ -764,33 +764,36 @@
             
-    break
+arr%5Bi+1%5D=key
 ;%0A          
@@ -802,51 +802,18 @@
     
-%7D%0A            %7D%0A            //arr%5Bk%5D=arr%5Bi%5D
+print(arr)
 ;%0A  
@@ -826,69 +826,42 @@
     
-%0A
     
-        arr%5Bk%5D=a;%0A        %7D%0A        %0A        print(arr);
+break;%0A            %7D%0A        %7D
 %0A   

add InsertionSort1.java