#include<cstdlib>
#include<cstdio>
using namespace std;
#define re register
#define cmax(a,b) ((a)>(b)?(a):(b))
int a[300100],c[300100],n;
bool check(re int x)
{
	int x1=0;
	for(re int i=2;i<=n;i+=2)
	{
		x1+=a[i-1];
		if(x1>=x&&x1<a[i])x1=0;
		else x1-=a[i];
	}x1+=a[n];
	return (x1>=x);
}
int main()
{
	re int w=0;
	scanf("%d",&n);
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);w+=a[i];c[i]=a[i];
		if(i>2)c[i]+=c[i-2];
	}if(n&1)
	{
		re int l=0,r=w;
		for(re int mid=(l+r+1)>>1;l<r;mid=(l+r+1)>>1)
		{
			if(check(mid))l=mid;else r=mid-1;
		}printf("%d %d\n",l+c[n-1],w-l-c[n-1]);
	}
	else 
	{
		if(c[n-1]>c[n])printf("%d %d",c[n-1],c[n]);
		else printf("%d %d",c[n],c[n-1]);
	}
}