var n,i,k,j,mi,ma:longint;
a:array[1..1000] of longint;
f,g:text;
begin
ma:=0;
assign(f,'cos.in');
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
mi:=9999;
for k:=1 to 9999 do begin
j:=k;
for i:=1 to n do begin
if j mod 2=0 then j:=j-(j div 2 +a[i] ) else j:=j-((j-1) div 2) -a[i];
if (j=0) and (i=n) and (mi>k) then mi:=k;
if j<0 then break;
end;
j:=k;
for i:=1 to n do begin
if j mod 2=0 then j:=j-(j div 2 +a[i] ) else j:=j-((j+1) div 2) -a[i];
if (j=0) and (i=n) and (ma<k) then ma:=k;
if j<0 then break;
end;

end;
assign(g,'cos.out');
rewrite(g);
writeln(g,ma);
writeln(g,mi);
close(g);
end.