var a:array[0..55000] of longint;{5000}
   i,j,k,n,p:longint;
   procedure sort(i:longint);
     var k:longint;
     begin
       if 2*i+1<=n then begin
       if (a[i]<a[2*i]) or (a[i]<a[2*i+1]) then
         begin
           sort(2*i);
           sort(2*i+1);
           if a[2*i]>a[2*i+1] then
             begin
{               sort(2*i);}
               k:=a[2*i];
               a[2*i]:=a[i];
               a[i]:=k;
               sort(2*i); 
             end else
             begin
{               sort(2*i+1);}
               k:=a[2*i+1];
               a[2*i+1]:=a[i];
               a[i]:=k;
               sort(2*i+1);
             end;
         end;
         end else
       if n=2*i then
       if (a[i]<a[2*i]) then
         begin
{           sort(2*i);}
           k:=a[2*i];
           a[2*i]:=a[i];
           a[i]:=k;
           sort(2*i);
         end;
     end;
   begin
     assign(input,'heapsort.in');
     reset(input);
     assign(output,'heapsort.out');
     rewrite(output);
     read(n);
     a[1]:=1;
     for i:=2 to n do
       begin
         k:=a[1];
         a[1]:=a[i-1];
         a[i-1]:=k;
{         if i>1 then sort(2);
         if i>2 then sort(3);}
{         for j:=i-1 downto 1 do
           sort(j);}
         k:=i-1;
         if k>3 then
         repeat
           p:=a[k div 2];
           a[k div 2]:=a[k];
           a[k]:=p;
           k:=k div 2;
         until (k=2) or (k=3);
         a[i]:=1;
         a[1]:=i;
{         for j:=1 to n do
           write(a[j],' ');writeln;}
       end;
     for i:=1 to n do
       write(a[i],' ');writeln;
    close(input);
    close(output);
   end.