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