#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3e5+5;
int n,a[N],foo,bar;
bool check(int mid){
	int mn=0;
	for(int i=2;i<n;i+=2)
		if(a[i-1]-mn>=mid)
			mn=min(mn,a[i]);
	return a[n]-mn>=mid;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(i&1)foo+=a[i];
		else bar+=a[i],a[i]=-a[i];
		a[i]+=a[i-1];
	}
	if(~n&1)return printf("%d %d\n",max(foo,bar),min(foo,bar)),0;
	int l=0,r=3e8,res;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))res=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d %d\n",bar+res,foo-res);
	return 0;
}
