program prH;

{$APPTYPE CONSOLE}
 var
   Heap: array[1..50005] of integer;
   HL: integer;
   n, i: integer;

   Procedure RHeapSort;
     var i, pr, v: integer;
    begin
     i := HL;
     v := Heap[i];
     pr := i shr 1;
     while i <> 1 do
      begin
       Heap[i] := Heap[pr];
       i := pr;
       pr := i shr 1;
      end;
     Inc(HL);
     Heap[1] := HL;
     Heap[HL] := v;
    end;



begin
  assign(input, 'heapsort.in');
  reset(input);
  assign(output, 'heapsort.out');
  rewrite(output);
  HL := 1;
  Heap[HL] := 1;
  read(n);
  while HL < n do RHeapSort;
  for i := 1 to n do write(Heap[i], ' ');
end.

