#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ans,a[N],s[N][2];
bool check(int mid){
	int las=0;
	for (int i=2;i<=n;i+=2)
	if (s[i-1][1]-s[i-1][0]-las>=mid) las=min(las,s[i][1]-s[i][0]);
	return (s[n][1]-s[n][0]-las>=mid);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		s[i][0]=s[i-1][0];
		s[i][1]=s[i-1][1];
		s[i][i&1]+=a[i];
	}
	if (n&1){
		int l=0,r=s[n][0]+s[n][1],mid;
		while (l<r){
			mid=(l+r+1)>>1;
			if (check(mid)) l=mid;
			else r=mid-1;
		}
		printf("%d %d\n",s[n][0]+l,s[n][1]-l);
	}
	else printf("%d %d\n",max(s[n][0],s[n][1]),min(s[n][0],s[n][1]));
	return 0;
}