#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <queue>
using namespace std;
const int maxn = 1010;
int temp[maxn],initial[maxn],n;
int ind;
void inorder(int root){//中序遍历
if(root > n){
return;
}
inorder(2 * root);//左子节点
temp[root] = initial[ind++];
inorder(2 * root + 1); //右子节点
}
int main(){
scanf("%d",&n);
for(int i =0;i<n;++i){
scanf("%d",&initial[i]);
}
sort(initial,initial+n);
inorder(1);
for(int i =1;i<=n;++i){
if(i != n){
printf("%d ",temp[i]);
}else{
printf("%d",temp[i]);
}
}
system("pause");
return 0;
}