#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=3e5+10;
int a[N],n,ans,ans2;
bool check(int lim){
	int now=0;
	for (int i=2;i<=n;i+=2){
		now+=a[i-1]-a[i-2];
		if (now>=lim)now=max(now,a[i]);
	}
	return now+a[n]-a[n-1]>=lim;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),ans2+=a[i];
	if (~n&1){
		int sum1=0,sum2=0;
		for (int i=1;i<=n;i++)sum1+=a[i]*(i&1),sum2+=a[i]*(~i&1);
		cout<<max(sum1,sum2)<<' '<<min(sum1,sum2)<<endl;
		return 0;
	}
	for (int u=1<<30;u;u>>=1)
		if (check(ans+u))ans+=u;
	for (int i=2;i<=n;i+=2)ans+=a[i];
	cout<<ans<<' '<<ans2-ans<<endl;
}