program h;
{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  maxh = 50000;

type
  THeap = record
            len : longint;
            h : array [1..maxh] of longint;
          end;

var
  heap : THeap;

procedure incl(n : integer);
var
  i, j : longint;
begin
  if heap.len = 0 then
  begin
    heap.len := 1;
    heap.h[1] := 1;
  end else
  begin
    i := heap.len;
    while i <> 1 do
    begin
      j := heap.h[i];
      heap.h[i] := heap.h[i div 2];
      heap.h[i div 2] := j;
      i := i div 2;
    end;
    inc(heap.len);
    heap.h[heap.len] := heap.h[1];
    heap.h[1] := n;    
  end;
end;

var
  f : text;
  nn, i : longint;
begin
  assign(f, 'heapsort.in');
  reset(f);
  readln(f, nn);
  close(f);
  heap.len := 0;
  for i := 1 to nn do incl(i);

  assign(f, 'heapsort.out');
  rewrite(f);
  for i := 1 to nn do write(f, heap.h[i], ' ');
  close(f);

end.
