#include <cstring>
#include <fstream>
#include <algorithm>

using namespace std;

inline int tabs(int x)
{
	return x < 0 ? -x : x;
}

int N, V[1002];
int result[550];

void inm()
{
	for (int i = 1; i <= result[0]; ++i)
		result[i] *= 2;
	for (int i = 1; i <= result[0]; ++i)
		if (result[i] >= 10)
		{
			result[i + 1] += result[i] / 10;
			result[i] %= 10;
			result[0] = max(result[0], i + 1);
		}
}
void add(int value)
{
	result[1] += value;
	for (int i = 1; i <= result[0] && result[i] >= 10; ++i)
	{
		result[i + 1] += result[i] / 10;
		result[i] %= 10;
		result[0] = max(result[0], i + 1);
	}
}
void decr()
{
	--result[1];
	for (int i = 1; i < result[0] && result[i] < 0; ++i)
	{
		result[i] += 10;
		--result[i + 1];
	}
	while (result[0] > 1 && result[result[0]] == 0) --result[0];
}

int main()
{
	ifstream fin("cos.in");
	ofstream fout("cos.out");
	
	fin >> N;
	for (int i = 1; i <= N; ++i)
		fin >> V[i];
	
	result[0] = 1;
	for (int i = N; i >= 1; --i)
	{
		V[i] *= 2, ++V[i];
		inm();
		add(V[i]);
	}
	
	for (int i = result[0]; i >= 1; --i)
		fout << result[i];
	fout << '\n';
	
	memset(result, 0, sizeof(result));
	result[0] = 1;
	for (int i = N; i >= 1; --i)
	{
		V[i] -= 2;
		inm();
		
		if (V[i] >= 0) add(V[i]);
		else if (result[0] != 1 || result[1] != 0) decr();
	}
	
	for (int i = result[0]; i >= 1; --i)
		fout << result[i];
	
	fin.close();
	fout.close();
}
