#include<iostream>usingnamespace std;constint MAXN =1005;int n, len;int a[MAXN], heap[MAXN];voidput(int);voidpop();intget();intmain(){
cin >> n;for(int i =1; i <= n; i++) cin >> a[i],put(a[i]);for(int i =1; i <= n; i++) cout <<get()<<" ",pop();return0;}voidput(int x){
heap[++len]= x;int fa, now = len;while(now >1){
fa = now >>1;if(heap[fa]<= heap[now])break;swap(heap[fa], heap[now]);
now = fa;}return;}intget(){return heap[1];}voidpop(){
heap[1]= heap[len--];int son, now =1;while((now <<1)<= len){
son = now <<1;if(heap[son +1]<= heap[son]) son = son +1;if(heap[now]<= heap[son])break;swap(heap[now], heap[son]);
now = son;}return;}