#include <cstdio>
#define nmax 1005
typedef long numar[503]; 
using namespace std;

long i, n, t, k, poz, x, ii, lm;
numar nr[nmax], xmin, xmax, p1;

void suma(numar &a, numar b)
{
	lm=a[0];	t=0;
	if (b[0]>lm)
		lm=b[0];
	for (i=1;i<=lm;i++)
	{
		k=a[i]+b[i]+t;
		a[i]=k%10;	t=k/10;
	}
	a[0]=lm;
	if (t>0)
		a[++a[0]]=t;
}

void dif()
{
	poz=1;
	while (xmin[poz]==0)
	{	xmin[poz]=9;	poz++;	}
	xmin[poz]--;
	if (xmin[xmin[0]]==0)
		xmin[0]--;
}

void sum()
{
	poz=1;	
	while (xmax[poz]==9)
	{	xmax[poz]=0;	poz++;	}
	xmax[poz]++;
	if (poz>xmax[0])
		xmax[0]=poz;
}

void afisare(numar a)
{
	for (i=a[0];i>=1;i--)
		printf("%ld",a[i]);
	printf("\n");
}

int main()
{
	freopen("cos.in","r",stdin);
	freopen("cos.out","w",stdout);
	p1[0]=1;	p1[1]=1;	
	scanf("%ld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&x);
		while (x>0)
		{	nr[i][++nr[i][0]]=x%10;		x=x/10;		}
	}
	for (ii=n;ii>=1;ii--)
	{
		//xmin=(xmin+nr[i])*2-1;
		suma(xmin, nr[ii]);	
		suma(xmin, xmin);	
		dif();
		//xmax=(xmax+nr[i])*2+1;
		suma(xmax,nr[ii]);	
		suma(xmax,xmax);
		sum();
	}
	afisare(xmax);
	afisare(xmin);
	return 0;
}
