program savey;
type
sss=array[0..400]of integer;
s=record
a:sss;
end;
var
i,j,k,l:longint;
n,o:longint;
f:array[1..1000]of s;
w:array[1..1000]of integer;
c:char;
m:sss;
procedure suan(const x:longint);
var
i,j,k:longint;
begin
k:=1;
for i:=1 to f[x-1].a[0] do
begin
f[x].a[i]:=f[x-1].a[i]*2+k;
k:=f[x].a[i] div 10;
f[x].a[i]:=f[x].a[i] mod 10;
end;
if k<>0 then
begin
f[x].a[f[x-1].a[0]+1]:=k;
f[x].a[0]:=f[x-1].a[0]+1;
end
else
f[x].a[0]:=f[x-1].a[0];
end;
procedure jian(const x:longint);
var
i,j,k,l:longint;
p:sss;
begin
k:=0;
for i:=1 to 400 do
p[i]:=0;
for i:=1 to f[x].a[0] do
begin
p[i]:=f[x].a[i]-m[i]-k;
if p[i]<0 then
begin
p[i]:=p[i]+10;
k:=1;
end
else
k:=0;
end;
if p[f[x].a[0]]=0 then
p[0]:=f[x].a[0]-1
else
p[0]:=f[x].a[0];
m:=p;
end;
begin
assign(input,'savey.in');
reset(input);
assign(output,'savey.out');
rewrite(output);
f[1].a[0]:=1;
f[1].a[1]:=1;
readln(n);
for i:=2 to n do
suan(i);
i:=0;
m[0]:=1;
m[1]:=0;
repeat
read(c);
if c<>' ' then
begin
inc(i);
if c='1' then
jian(i);
end;
until i=n;
for i:=m[0] downto 1 do
write(m[i]);
writeln;
close(input);
close(output);
end.