#include <iostream>
#include <vector>
using namespace std;
class heap{
private:
vector<int> v;
int pred(int n){return (n-1)/2;};
int next(int n){return (v[n*2+1]>v[n*2+2])?n*2+1:n*2+2;};
int del(){
int ans=v[0];
v[0]=0;
int m=0;
int n=next(m);
while(v[m]<v[n]&&n<=v.size()){
swap(v[m],v[n]);
m=n;
n=next(m);
};
v.resize(v.size()-1);
return ans;
}
public:
void add(int n){
v.push_back(n);
int m=v.size()-1;
int p=pred(m);
while((v[m]>v[p])&&(m>0)){
swap(v[m],v[p]);
m=p;
p=pred(m);
};
};
void sort(vector<int>& w){
while(v.size())w.push_back(del());
};
};
int main()
{
int n,m;
heap h;
cin>>n;
for(int i=0;i<n;i++){
cin>>m;
h.add(m);
};
vector<int> v;
h.sort(v);
for(int i=0;i<n;i++)cout<<v[i]<<' ';
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIGhlYXB7CnByaXZhdGU6CiAgICB2ZWN0b3I8aW50PiB2OwogICAgaW50IHByZWQoaW50IG4pe3JldHVybiAobi0xKS8yO307CiAgICBpbnQgbmV4dChpbnQgbil7cmV0dXJuICh2W24qMisxXT52W24qMisyXSk/bioyKzE6bioyKzI7fTsKICAgIGludCBkZWwoKXsKICAgICAgICBpbnQgYW5zPXZbMF07CiAgICAgICAgdlswXT0wOwogICAgICAgIGludCBtPTA7CiAgICAgICAgaW50IG49bmV4dChtKTsKICAgICAgICB3aGlsZSh2W21dPHZbbl0mJm48PXYuc2l6ZSgpKXsKICAgICAgICAgICAgc3dhcCh2W21dLHZbbl0pOwogICAgICAgICAgICBtPW47CiAgICAgICAgICAgIG49bmV4dChtKTsKICAgICAgICB9OwogICAgICAgIHYucmVzaXplKHYuc2l6ZSgpLTEpOwogICAgICAgIHJldHVybiBhbnM7CiAgICB9CnB1YmxpYzoKICAgIHZvaWQgYWRkKGludCBuKXsKICAgICAgICB2LnB1c2hfYmFjayhuKTsKICAgICAgICBpbnQgbT12LnNpemUoKS0xOwogICAgICAgIGludCBwPXByZWQobSk7CiAgICAgICAgd2hpbGUoKHZbbV0+dltwXSkmJihtPjApKXsKICAgICAgICAgICAgc3dhcCh2W21dLHZbcF0pOwogICAgICAgICAgICBtPXA7CiAgICAgICAgICAgIHA9cHJlZChtKTsKICAgICAgICB9OwogICAgfTsKICAgIHZvaWQgc29ydCh2ZWN0b3I8aW50PiYgdyl7CiAgICAgICAgd2hpbGUodi5zaXplKCkpdy5wdXNoX2JhY2soZGVsKCkpOwogICAgfTsKfTsKCmludCBtYWluKCkKewogICAgaW50IG4sbTsKICAgIGhlYXAgaDsKICAgIGNpbj4+bjsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGNpbj4+bTsKICAgICAgICBoLmFkZChtKTsKICAgICAgICB9OwogICAgdmVjdG9yPGludD4gdjsKICAgIGguc29ydCh2KTsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspY291dDw8dltpXTw8JyAnOwogICAgcmV0dXJuIDA7Cn0K