#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
void read(int&x){
	x=0;char c=getchar();
	while (!isdigit(c))c=getchar();
	while (isdigit(c))x=x*10+c-'0',c=getchar();
}
#define maxn 300005



int n,a[maxn];
void solve_even(){
	int odd=0,even=0;
	rep(i,1,n)if (i&1)odd+=a[i];else even+=a[i];
	printf("%d %d\n",max(odd,even),min(odd,even));
}
bool check(int mid){
	int s=0;
	for (int i=1;i<=n;i+=2){
		s+=a[i];bool flag=false;if (s>=mid)flag=true;
		s-=a[i+1];if (flag&&s<0)s=0;
	}
	return s>=mid;
}
void solve_odd(){
	int s=0;rep(i,1,n)s+=a[i];
	int l=-s,r=s;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid))l=mid+1;else r=mid-1;
	}
	rep(i,1,n)if (~i&1)r+=a[i];
	printf("%d %d\n",r,s-r);
}
int main(){
	read(n);rep(i,1,n)read(a[i]);
	if (~n&1)solve_even();else solve_odd();
	return 0;
}