#include<iostream>
#include<cstdio>
using namespace std;
int n,B,W;
const int N=300010;
int a[N],sum[N];
int check(int mid)
{
	int mn=0;
	for(int i=2;i<n;++i)
		if(mn<=sum[i-1]-mid)mn=min(mn,sum[i]);
	return mn<=sum[n]-mid;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);sum[i]=sum[i-1];
		if(i&1)B+=a[i],sum[i]+=a[i];
		else W+=a[i],sum[i]-=a[i];
	}
	if(!(n&1))return printf("%d %d",max(B,W),min(B,W))==2333;
	int L=-3e8,R=3e8,pos=0,ans;
	while(L<=R)
	{
		int mid=(L+R)/2;
		if(check(mid))pos=mid,L=mid+1;
		else R=mid-1;
	}
	ans=max(W+pos,B);
	cout<<ans<<" "<<W+B-ans;
	return 0;
}