#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=300000 +117;
const int MM=300000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
int pre[NN]={};
bool chk(int x){
	int mii=0;
	for(int i=2;i<=n;i+=2){
		if(pre[i-1]-mii>=x){
			mii=min(mii,pre[i]);
		}
	}
	return pre[n]-mii>=x;
}
int main(){
	//open();
	n=read();
	int s=0;
	int s1=0;
	int s2=0;
	for(int i=1;i<=n;++i){
		a[i]=read();
		s+=a[i];
		pre[i]=a[i];
		if(i&1){
			s1+=a[i];
		}
		else{
			s2+=a[i];
			pre[i]=-pre[i];
		}
		pre[i]+=pre[i-1];
	}
	int ans=max(s1,s2);
	if(n&1){
		int l=0,r=s;
		while(l!=r){
			int mid=(l+r+1)>>1;
			if(chk(mid)){
				l=mid;
			}
			else r=mid-1;
		}
		ans=max(ans,s2+l);
	}
	printf("%d %d\n",ans,s-ans);
	close();
	return 0;
}