#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAXN1000
int A[MAXN],B[MAXN+1];
int Cmp(constvoid* a,constvoid* b);voidPrint(int*B, int N);voidReCBTree(int index, int left, int right);
int Log2(int x);
int Min(int a, int b);
int main(){
int N, i;scanf("%d",&N);for(i =0; i <N; i++)scanf("%d",&A[i]);qsort(A,N,sizeof(int), Cmp);ReCBTree(1,0,N-1);Print(B,N);return0;}
int Cmp(constvoid* a,constvoid* b){return*(int*)a -*(int*)b;}voidPrint(int*B, int N){
int flag =1, i;for(i =1; i <=N; i++){if(flag) flag =0;elseprintf(" ");printf("%d",B[i]);}}voidReCBTree(int index, int left, int right){if(left > right)return;
int h, x, nl;
int N= right - left +1;
h =Log2(N+1);
x =Min((int)pow(2, h -1),N-(int)pow(2, h)+1);
nl = x +(int)pow(2, h -1)-1;B[index]=A[left + nl];ReCBTree(index *2, left, left + nl -1);ReCBTree(index *2+1, left + nl +1, right);}
int Log2(int x){
int i=0;while((int)pow(2, i)<= x) i++;return i -1;}
int Min(int a, int b){return a < b ? a : b;}