program ProjectH;

uses
  SysUtils, Math;

var
  i, j, N, buf: Word;
  a, al, ar: array [1..256] of Longint;
  fin, fout: TextFile;

begin
  AssignFile(fin, 'input.txt');
  reset(fin);

  AssignFile(fout, 'output.txt');
  rewrite(fout);

  read(fin, N);

  for i:=1 to N do
    read(fin, a[i]);



  i:=0;
  while power(2, i) < n do
    begin
      for j:=1 to round(power(2, i)) do
        begin
          buf := a[j];
          a[j] := (a[j] + a[j+round(power(2, i))]) div 2;
          a[j+round(power(2, i))] := (buf - a[j+round(power(2, i))]) div 2;
        end;

      for j:=1 to round(power(2, i)) do
        al[j] := a[j];

      for j:=round(power(2, i))+1 to 2*round(power(2, i)) do
        ar[j - round(power(2, i))] := a[j];

      for j:=1 to round(power(2, i)) do
        begin
          a[j*2-1] := al[j];
          a[j*2] := ar[j];
        end;

      i:=i+1;
    end;

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

  CloseFile(fin);
  CloseFile(fout);
end.

