program savey;
type number=record
s:array[1..5000]of longint;
len:longint;
end;
var A,B:array[1..10100]of longint;
n,i:longint;
x,sum:number;
procedure add(a,b:number; var c:number);
var i,max:longint; d:number;
begin
fillchar(d.s,sizeof(d.s),0);
max:=a.len; if b.len>a.len then max:=b.len;
for i:=1 to max do d.s[i]:=a.s[i]+b.s[i];
d.len:=max;
for i:=1 to max do
begin
d.s[i+1]:=d.s[i+1]+d.s[i] div 10;
d.s[i]:=d.s[i] mod 10;
end;
if d.s[max+1]>0 then inc(d.len);
c:=d;
end;
procedure mul(a:number; var c:number);
var i:longint; d:number;
begin
fillchar(d.s,sizeof(d.s),0);
for i:=1 to a.len do d.s[i]:=d.s[i]+a.s[i]*2;
for i:=1 to a.len+1 do
begin
d.s[i+1]:=d.s[i+1]+d.s[i] div 10;
d.s[i]:=d.s[i] mod 10;
end;
d.len:=a.len+1;
while d.s[d.len]=0 do dec(d.len);
c:=d;
end;
begin
assign(input,'savey.in'); reset(input);
assign(output,'savey.out'); rewrite(output);
readln(n);
for i:=n downto 1 do read(A[i]);
B[1]:=A[1];
for i:=2 to n do B[i]:=A[i] xor B[i-1];//格雷码解码成二进制
sum.len:=1; sum.s[1]:=0;
x.s[1]:=1; x.len:=1;
for i:=n downto 1 do
begin
if B[i]=1 then add(x,sum,sum);
mul(x,x);
end; //二进制转十进制
for i:=sum.len downto 1 do write(sum.s[i]);
writeln;
close(input); close(output);
end.