#include <iostream>
using namespace std;

int main() {
	 int n;
	 int i,j,temp;
	 
	 cout << "Please enter array elements size to sort" << endl;
	 cin >> n;
	 
	 int a[n];

	 cout << endl <<  "Please enter array of size " << n << endl;
		  	 
	 for(i=0;i<n;i++){
       	cin >> a[i];		  
     }
	 
	 cout << endl <<  "the array before sorting is: " << endl;
	 
	  for(i=0;i<n;i++){
        cout << a[i] << "\t";
      }	
	  
	  /* insertion sort */
	  for(i=1;i<n;i++){
	  	for(j=0;j<i;j++){
			 if(a[i] < a[j]){
 		          temp = a[i];
 		          a[i] = a[j];
 		          a[j] = temp;
			 }
		}	   
	  } 	
	  
	  cout << endl <<  "the array after sorting is: " << endl;
	  
      for(i=0;i<n;i++){
        cout << a[i] << "\t";
      }	 
	 	
	return 0;
}