#include<cstdio>
#include<algorithm>
#define maxn 1010
using namespace std;
struct node
{
int data;
}tree[maxn];
int head = 1,cnt=0,N,input[maxn]={0};
int output[maxn]={0};
void in_order(int head)
{
//判空是head>N
if(head > N) return;
in_order(head*2);
output[head] = input[cnt++];
in_order(head*2+1);
}
int main()
{
//输入数据
scanf("%d",&N);
for(int i=0 ;i<N; i++)
scanf("%d",&input[i]);
sort(input, input+N);
//中序遍历时,从小到大填入数据
in_order(1);
//从1开始输出数据!
for(int i=1; i<=N; i++)
{
if(i == 1) printf("%d",output[i]);
else printf(" %d",output[i]);
}
return 0;
}