program Project2;

{$APPTYPE CONSOLE}

const
        maxn=50000;

function parent(i: integer): integer;
begin
        parent:=i shr 1;
end;

var
        FileIn,FileOut:text;
        n, i, j, current:integer;
        a: array[1..maxn] of integer;

procedure change(i, j: integer);
var
        temp: integer;
begin
        temp:=a[i];
        a[i]:=a[j];
        a[j]:=temp;
end;

begin
  assign(FileIn,'heapsort.in');
  assign(FileOut,'heapsort.out');
  rewrite(FileOut);
  reset(FileIn);

  read(fileIn, n);
  for i:=1 to n do
        a[i]:=i;
  for j:=2 to n do
  begin
        current:=j-1;
        while (current<>1) do begin
                change(current, parent(current));
                current:=parent(current);
        end;
        change(1, j);
  end;

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


  close(FileIn);
  close(FileOut);
end.
