#include<cstdio>
#include<cstdlib> 
int n,a[300010];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
void cmin(int&a,int b){b<a?a=b:1;}
void cmax(int&a,int b){b>a?a=b:1;}
int g[300010],sum[300010];
int calc(){
	int s[2]={0};
	for(int i=0;i<n;i++)s[i%2]+=a[i];
	if(n%2==0)return max(s[0],s[1]);
	sum[n]=0;
	for(int i=n;i--;)sum[i]=sum[i+1]+(i&1?-a[i]:a[i]);
	int left=0,right=1<<29,mid;
	while(right-left>1){
		mid=left+right>>1;
		int val=0;
		for(int i=n-1;i;i-=2){
			if(sum[i]-val>=mid)cmin(val,sum[i-1]);
		}
		if(sum[0]-val>=mid)left=mid;
		else right=mid;
	}
	return s[1]+left;
}
int main(){
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<n;i++)scanf("%d",a+i),sum+=a[i];
	int ans=calc();
	printf("%d %d\n",ans,sum-ans);
}