 var f:textfile;
     n:integer;
     a:array[1..50000] of integer;

procedure Create;
 var i,u,t:integer;
begin
 a[1]:=1;
 if n=1 then exit;
 for i:=2 to n do begin
  while true do begin
   t:=a[u];
   a[u]:=a[u div 2];
   a[u div 2]:=t;
   if a[1]=1 then break;
   u:=u div 2;
  end;
  a[1]:=i; a[i]:=1;
  u:=i;
 end;
end;

 var i:integer;
begin
 AssignFile(f,'heapsort.in');
 reset(f);
 readln(f,n);
 CloseFile(f);

 Create;

 AssignFile(f,'heapsort.out');
 rewrite(f);
 for i:=1 to n do
  write(f, a[i], ' ');
 writeln(f);
 closefile(f);
end.
