program ProblemH;

{$APPTYPE CONSOLE}

const MAXN = 100000;

function level(i: integer): integer;
begin
    result := 0;
    while (i > 1) do begin
        inc(result);
        i := i shl 1
    end
end;

procedure swap(var a, b: integer);
var
    t: integer;
begin
    t := a;
    a := b;
    b := t;
end;

var
    a: array[1..MAXN] of integer;
    i, j, n, m, mi, cl: integer;


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
        a[i] := i;
        m := a[i - 1]; mi := i - 1;
        cl := level(mi);
        for j := i - 1 downto 1 do begin
            if (level(j) < cl) then break;
            if (a[j] < m) then begin
                m := a[j];
                mi := j;
            end
        end;
        j := mi;
        while (j > 1) do begin
            cl := j shr 1;
            swap(a[cl], a[j]);
            j := cl
        end;
        swap(a[1], a[i]);

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