#include<cstdio>
int n,m,a[300011],l,r,sum[2],s;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)sum[i%2]=sum[i%2]+a[i];
	if((n%2)==1)
	{
		int l=1,r=2000000000;
		while(l<r)
		{
			int mid=(l+r+1)/2;
			s=0;
			for(int i=1;i<=n;i++)
			{
				if((i%2)==1)s=s+a[i];
				else 
				{
					if((s>=mid)&&(s-a[i]<0))s=0;
					else s=s-a[i];
				}
			}
			if(s>=mid)l=mid;
			else r=mid-1; 
		}
		sum[0]=sum[0]+l;
		sum[1]=sum[1]-l;
	}
	if(sum[0]>sum[1])printf("%d %d\n",sum[0],sum[1]);
	else printf("%d %d\n",sum[1],sum[0]);
}