{
    Решение избранных задач
    © 2024 Слинкин Д.А., GNU LGPLv3

 **********************************************************************}

{$mode objfpc}

procedure speedsort(var a:array of integer; Left,Right:integer);
 var L,R,center,sw:integer;
begin
 if left>right then exit;
 center:=a[(left+right)div 2];
 L:=left; R:=Right;
 repeat
    while a[L]<center do inc(L);
    while a[R]>center do dec(R);
    if L<=R then begin
        sw:=a[L]; a[L]:=a[R]; a[R]:=sw;
        inc(L); dec(R);
    end;
 until L>R;
 speedsort(a,Left,R);
 speedsort(a,L,Right);
end;


var a:array of integer;
    count,i,inLeft,inRight:integer;
    chet:boolean;
begin
 readln(count);
 setLength(a,count);
 for i:=0 to count-1 do read(a[i]);
 readln;
 // сортируем в порядке возрастания масс
 // достаточно один раз, затем выедать середину
 speedsort(a,0,count-1);

 // поглощение начинается с середины
 inRight:=count div 2; // медиана
 inLeft:=inRight-1;
 chet:=not odd(count); // четность кол-ва
 while count<>0 do begin
    if chet then begin
        write(a[inLeft],' '); // пожираем слева 
        dec(inLeft);
    end
    else begin
        write(a[inRight],' '); // пожираем справа
        inc(inRight);
    end;
    chet:=not chet; // инвертирование четности
    dec(count);
 end;
 writeln;

end.