#include <fstream>
using namespace std;
#define NMax 1000
#define LgMax 1000

typedef int NrMare[LgMax];


void scrie(NrMare x, int lg);
void prod2(NrMare x, int &lg);
void conv(int nr, NrMare x, int& lgx);
void suma(NrMare x, int &lx, NrMare y, int ly); //x+=y;
void dif(NrMare x, int lx, NrMare y, int ly, NrMare z, int &lz); //z=x-y
int  maimic(NrMare x, int lx, NrMare y, int ly); //x<y?

int N;
int nr[NMax];

NrMare jum, p, minim, maxim, unu;
int    lgj, lgp, lgmin, lgmax, lg1;

ofstream fout("cos.out");

int main()
{
 ifstream fin("cos.in");
 int i;
 NrMare x;
 int lgx, lg1;
 fin>>N;
 for (i=0; i<N; i++) fin>>nr[i];
 lgj=lgp=1;
 p[0]=1; //initializez puterea cu 1
 jum[0]=0;//initializez jumatatea cu 0

 for (i=N-1; i >= 0; --i)
     {
        conv(nr[i], x, lgx);
        suma(jum, lgj, x, lgx);
        prod2(jum, lgj);
        prod2(p,lgp);
    }

 //max=jum+p-1
 //min=jum-p+1 sau 0

 unu[0]=1; lg1=1;
 dif(p, lgp, unu, lg1, maxim,lgmax);
 suma(maxim, lgmax, jum, lgj);

 if (maimic(jum,lgj,p, lgp)) {minim[0]=0; lgmin=1;}
    else
    {
    dif(jum, lgj, p, lgp, minim, lgmin);
    suma(minim, lgmin, unu, lg1);
    }
 scrie(maxim, lgmax);
 scrie(minim, lgmin);


 fout.close();
 return 0;
}


void scrie(NrMare x, int lg)
{
int i;
for (i=lg-1; i>=0; i--) fout<<(int)x[i];
fout<<'\n';
}

void prod2(NrMare x, int &lg)
{
int t=0, i, s;
for (i=0; i<lg; i++)
    {s=x[i]*2+t;
     x[i]=s%10;
     t=s/10;}
if (t) x[lg++]=t;
}

void conv(int nr, NrMare x, int& lg)
{
lg=0;
while (nr)
      {x[lg++]=nr%10;
       nr/=10;}
}


void suma(NrMare x, int &lx, NrMare y, int ly) //x+=y;
{
int i, t=0, s, mic, mare;
if (lx<ly)
   {mic=lx; mare=ly; for (i=mic; i<mare; i++) x[i]=0;}
   else
   {mic=ly; mare=lx; for (i=mic; i<mare; i++) y[i]=0;}

for (i=0; i<mare; i++)
     {s=x[i]+y[i]+t;
     x[i]=s%10;
     t=s/10;  }
if (t) {lx=mare+1; x[lx-1]=t;}
   else lx=mare;
}

void dif(NrMare x, int lx, NrMare y, int ly, NrMare z, int &lz) //z=x-y
{
int i, t=0, s;
for (i=lx; i<ly; i++) y[i]=0;
for (i=0; i<lx; i++)
    {s=x[i]-y[i]+t;
     if (s<0)
        {t=-1; s+=10; z[i]=s;}
        else
        {t=0; z[i]=s;}
    }
for (lz=lx; lz>1 && z[lz-1]==0; lz--);
}

int  maimic(NrMare x, int lx, NrMare y, int ly) //x<y?
{
int i;
if (lx<ly) return 1;
if (lx>ly) return 0;
for (i=lx-1; i>=0; i--)
    {if (x[i]<y[i]) return 1;
    if (x[i]>y[i]) return 0;}
return 0;
}
