#include<bits/stdc++.h>
using namespace std;

int max_ind(vector<int> &a, int l, int r){
int maxi = l;
for(int i=l;i<=r;i++){
if(a[maxi]<a[i])
maxi = i;
}
return maxi;
}

void max_number(vector<int> &v, int swaps){
for(int j=0;(j<v.size()) && (swaps >0);j++){
int max_index = max_ind(v, j, j+swaps);
int k = max_index;
if(j != max_index){
while(max_index > j){
swap(v[max_index], v[max_index-1]);
max_index--;
}
}
swaps -= abs(k - j);
}
}

int main()
{
int n,swaps=1;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++)
{
      cin>>v[i];
}
if(n==2)
{
    cout<<v[1]<<" "<<v[0];
    return 0;
}
max_number(v, swaps);
for(int i=0;i<n;i++)
cout<<v[i]<<" ";
cout<<endl;
}