program Project2;

uses
  SysUtils;

Var f:text;
    m:array[1..256] of Integer;
    N,I,k: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
    z:=m[1];
    for I:=0 to N-1 do
      begin
        Make(z,m[2*I+1+N],x,y);
        z:=m[2*I+2];
        m[2*I+1]:=x; m[2*I+2]:=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;
           end;
    end;

  Close(f);

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

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

  Close(f);


end.
 