#include <fstream>
using namespace std;

const int N=1005,M=800;
int v[N],minim[M],maxim[M],n,D=-1;
char PRINT[5*N];

ifstream in("cos.in");
ofstream out("cos.out");

void add(int v[],int t)
{
	int i;
	for (i=1;t;i++,t/=10)
		v[i]=(t+=v[i])%10;
	if (v[0]<i)
		v[0]=i-1;
}

void prod(int v[],int x)
{
	int i,t=0;
	for (i=1;i<=v[0] || t;i++,t/=10)
		v[i]=(t+=v[i]*x)%10;
	v[0]=i-1;
}

void decrease(int v[])
{
	if (v[0]==1 && !v[1])
		return;
	v[1]--;
	for (int i=1;i<=v[0];i++)
	{
		if (v[i]>=0)
			break;
		v[i]+=10;
		v[i+1]--;
	}
	while (v[0]>1 && !v[v[0]])
		v[0]--;
}	

void proc(int v[],int x,int semn)
{
	prod(v,2);
	if (!x && semn==-1)
		decrease(v);
	else
		add(v,2*x+semn);
}

void print(int v[])
{
	for (int i=v[0];i;i--)
		PRINT[++D]=v[i]+'0';
	PRINT[++D]='\n';
}

int main()
{
	int i;
	in>>n;
	for (i=1;i<=n;i++)
		in>>v[i];
	minim[0]=maxim[0]=1;
	for (i=n;i;i--)
	{
		proc(minim,v[i],-1);
		proc(maxim,v[i],1);
	}
	print(maxim);
	print(minim);
	PRINT[++D]='\0';
	out<<PRINT;
	return 0;
}
