program Project2;

uses
  SysUtils;

var
	mas: array [0..50001] of integer;
  n, i, tmp: integer;


procedure unheap(x: integer);
var
	x1, x2, tmp: integer;
begin
	x1 := x;
	repeat
  	x2 := x1 div 2;
    if x2 = 0 then exit;
  	tmp := mas[x1];
    mas[x1] := mas[x2];
    mas[x2] := tmp;
    x1 := x2;
  until 2 = 1;
end;

begin
	assignfile(input, 'heapsort.in');
  assignfile(output, 'heapsort.out');
  reset(input);
  rewrite(output);
  //
	readln(n);
  for i := 1 to n do
  	mas[i] := i;
  for i := 2 to n do
  begin
    tmp := mas[1];
    mas[1] := mas[i];
    mas[i] := tmp;
    if i = n then break;
		unheap(i);
  end;
  for i := 1 to n do
  	write(mas[i], ' ');
end.
