program Project2;

uses
  SysUtils;

Var f:text;
    m,mm:array[1..256] of Integer;
    N,I,k,II:Word;

  Procedure Make(Add,Sub:Integer; Var x,y:Integer);
  Begin
    x:=(Add+Sub) div 2;
    y:=Add-x;
  End;

  Procedure Change(N:Word);
  Var I:Word;
      x,y,z:Integer;
  Begin
    for I:=1 to N do
      begin
        {if (I mod 2 <> 0) then z:=m[I];{}
        Make(m[I],m[I+N],x,y);
        {z:=m[2*I];{}
        mm[2*I-1]:=x; mm[2*I]:=y;
      end;
  End;

begin
  assign(f,'input.txt');
  ReSet(f);

  read(f,N);
  k:=1;
  for I:=1 to N do
    begin
      read(f, m[I]);
      if (I=2*k)
      then begin
             Change(k);
             k:=k*2;
             for II:=1 to k do
               m[II]:=mm[II];
           end;
    end;

  Close(f);

  assign(f,'output.txt');
  ReWrite(f);

  for I:=1 to N do
    write(f,m[I],' ');

  Close(f);


end.
 