{$APPTYPE CONSOLE}

uses
  SysUtils;

var
a:array[1..256] of integer;
b:array[1..256] of integer;
c:array[1..256] of integer;
i,j,n,nnn,k,k1:integer;
f,f2:text;
l,q,w:integer;
s,s1:AnsiString;
begin
assign(f,'input.txt');
reset(f);
readln(f,s);
close(f);
s1:='';
l:=1;
for i:=1 to length(s) do
  begin
    if (s[i] <> ' ') then
      s1:=s1+s[i]
    else
      begin
        if (l=1) then
          n:=StrToInt(s1)
        else
            a[l-1]:=StrToInt(s1);
          s1:='';
          l:=l+1;
      end;
  end;
  l:=l-1;
  a[l]:=StrToInt(s1);
  assign(f2,'output.txt');
  rewrite(f2);
  if n=2 then
    nnn:=1;
  if n=4 then
    nnn:=2;
  if n=8 then
    nnn:=3;
  if n=16 then
    nnn:=4;
  if n=32 then
    nnn:=5;
  if n=64 then
    nnn:=6;
  if n=128 then
    nnn:=7;
  if n=256 then
    nnn:=8;
  for i:=1 to n do
    b[i]:=a[i];
  k:=1;
  for i:=1 to nnn do
    begin
      k1:=1;
      for j:=1 to k do
        begin
          q:=round((b[j]+b[j+k])/2);
          w:=round((b[j]-b[j+k])/2);
          c[k1]:=q;
          c[k1+1]:=w;
          k1:=k1+2;
        end;
        for j:=1 to k+k do
            b[j]:=c[j];
      k:=k*2;
    end;
  for i:=1 to n-1 do
    begin
      write(f2,b[i]);
      write(f2,' ');
    end;
    write(f2,b[n]);
  close(f2);
end.

