//Insertion sort
import java.io.*;
public class Insertionsort
{   public static void main(String args[])throws IOException
{   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the size of array");
    int size=Integer.parseInt(br.readLine());
    int a[]=new int[size];
    System.out.println("Enter values");
    for(int i=0; i<a.length; i++) 
    {   System.out.print("Value "+(i+1)+" : ");
        a[i]=Integer.parseInt(br.readLine());
    }//for
    //Sorting
        for(int open=1; open<a.length; open++)
        {   int t=open;
            while(t>0 && a[t]<a[t-1])
            {   int temp=a[t];
                a[t]=a[t-1];
                a[t-1]=temp;
                t--;
            }//while
        }//for
        System.out.println("Contents of the array ");
        for(int i=0; i<a.length; i++) 
        {   System.out.println(a[i]);
        }
    }//main()
}//class
/*OUTPUT
Enter the size of array
5
Enter values
Value 1 : 6
Value 2 : 8
Value 3 : 5
Value 4 : 3
Value 5 : 6
Contents of the array 
3
5
6
6
8
*/
