program h;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
   n:integer;
   i,k,j:integer;
   a:array[1..110000]of integer;


function left(i:integer):integer;
begin
result:=i*2
end;

function right(i:integer):integer;
begin
result:=i*2+1
end;

function parent(i:integer):integer;
begin
result:=i div 2
end;

procedure heap(i,hs:integer);
var t,l,r,m:integer;
begin
l:=left(i);
r:=right(i);
{if a[i]=1 then k:=i;
if a[l]=1 then k:=l;
if a[r]=1 then k:=r;}
m:=i;
if (a[i]<a[l]) and (l<=hs) and(l>0) then m:=l;
if (a[m]<a[r]) and (r<=hs) and(r>0)then m:=r;

if m<>i then begin t:=a[m]; a[m]:=a[i]; a[i]:=t; heap(m,hs); end;
end;

procedure buildheap(hs:integer);
var i,k:integer;
begin
{for i:=hs div 2 downto 1 do}
k:=parent(hs-1);
while k>=1 do begin
heap(k,hs);
k:=parent(k);
end;

end;

begin
   assign(input,'heapsort.in');
   assign(output,'heapsort.out');
   reset(input);
   rewrite(output);

   readln(n);


   a[1]:=2; k:=1; a[2]:=1;
   for i:=3 to n do begin
      a[i-1]:=i; a[i]:=1;
    buildheap(i);
     end;



   for i:=1 to n do write(a[i],' ');
   writeln;


   close(input);
   close(output);

end.
