#include<cstdio>
using namespace std;
short a[1010];
int n;
long long minim=0,maxim=0;
int main()
{
	long long i,suma=0,sum,aux,limita=0,aux2;
	short gasit=0;
	int x,j;
	freopen("cos.in","r",stdin);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[i]=x;
		suma+=x;
	}
	i=suma;
	while(gasit<2)
	{
		sum=i;
		for(j=1;j<=n && sum>0;j++)
		{
			aux=sum;
			aux=aux/2;
			aux=aux+a[j];
			sum=sum-aux;
		}
		if(j==n+1 && sum==0)
		{
			if(minim==0)
			{
				gasit++;
				minim=i;
				limita=minim;
				limita+=suma;
				limita+=n;
				limita+=10000;
			}
			else
			{
				maxim=i;
			}
		}
		if(minim!=0 && i==limita)
			gasit++;
		if(minim!=0)
		{
			sum=i;
			for(j=1;j<=n && sum>0;j++)
			{
				aux=sum;
				aux2=sum;
				aux=aux/2;
				aux2=aux2%2;
				aux=aux+aux2;
				aux=aux+a[j];
				sum=sum-aux;
			}
			if(j==n+1 && sum==0)
				maxim=i;
		}
		i=i+1;
	}
	freopen("cos.out","w",stdout);
	printf("%lld\n",maxim);
	printf("%lld\n",minim);
	return 0;
}
