#include <bits/stdc++.h>
#define ll long long 			//-+ 9,223,372,036,854,775,807  = 9.2*10^18 = 2^63 - 1
#define ull unsigned long long	// +18,446,744,073,709,551,615  = 1.8*10^19 = 2^64 - 1
#define l long					//-+ 			 2,147,483,647	= 2.1*10^9  = 2^31 - 1
#define ul unisgned long		// +			 4,294,967,295	= 4.3*10^9	= 2^32 - 1
#define db double
#define ldb long double
#define ff(i,n) for(int i = 0; i < n; ++i)
#define fff(i,a,b) for(int i = a; i<=b; ++i)

using namespace std;
int niz[1000003];

void zameniti(int* mat, int gde, int sad)
{ 
    int aux = 0; 
    for(int i = sad;i > gde; i--) { 
        aux = mat[i - 1]; 
        mat[i - 1] = mat[i]; 
        mat[i] = aux; 
    } 
} 

void max(int* arr,int duz, int zamena) 
{ 

	if(duz == 2){
		int temp=arr[0];
		arr[0]=arr[1];
		arr[1]=temp;
	}
	else{
	
    if(zamena == 0) 
        return; 
  
    ff(i,duz) { 
        int max_index = 0, max = INT_MIN; 
  
        int limit = (zamena + i) > duz ?  duz : zamena + i; 
                        
        fff(j,i,limit){ 
            if(arr[j] > max) { 
                max = arr[j]; 
                max_index = j; 
            } 
        } 
  
        zamena -= (max_index - i); 
        zameniti(arr, i, max_index); 
  
        if (zamena == 0) 
            break; 
    } 
    } 
}

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    const int LIM=0;
    
    
    l n=0;
    cin>>n;
    ff(i,n){
    	cin>>niz[i];
	}
	
	max(niz,n,1);
	
	for (int i = 0; i < n; i++) { 
        cout << niz[i] << " "; 
    } 
	
	
	
	
    
	return 0;
}