//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn=300111;
struct data
{
	set<pair<ll,ll> >st;
	ll query(ll l)//query max(y) when x<=l
	{
		set<pair<ll,ll> >::iterator it=st.lower_bound(MP(l+1,-2e18));
		if(it==st.begin())return -2e18;
		else
		{
			it--;
			return it->SS;
		}
	}
	void add(ll x,ll y)//add (x,y)
	{
		if(query(x)>=y)return;
		st.insert(MP(x,y));
		while(true)
		{
			set<pair<ll,ll> >::iterator it=st.lower_bound(MP(x,y+1));
			if(it!=st.end()&&it->SS<=y)st.erase(it);else break;
		}
	}
	void init()
	{
		st.clear();
	}
}yxg1,yxg2;
int n;
int a[maxn],pre[maxn];
int dp0[maxn],dp1[maxn];
int cost(int i,int j)
{
	return pre[j]-pre[i-1];
}
void out(int x)
{
	int sum=0;
	for(int i=1;i<=n;i++)sum+=a[i];
//	cerr<<"sum="<<sum<<endl;
	assert((sum+x)%2==0);
	cout<<(sum+x)/2<<" "<<(sum-x)/2<<endl;
}
void calcdp(int dp[])
{
	static int A[maxn],B[maxn];
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(i&1?a[i]:-a[i]);
	yxg1.init();
	yxg2.init();
	for(int i=1;i<=n;i+=2)
	{
		dp[i]=cost(1,i);
		int X=pre[i];
//		dp[i]=max(dp[i],min(dp[j-1]-cost(j,i),cost(j+1,i)-cost(1,j)));
//		dp[i]=max(dp[i],min(dp[j]-pre[i]+pre[j],pre[i]-2*pre[j+1]));
//		dp[i]=max(dp[i],min(dp[j]-X+pre[j],X-2*pre[j+1]));
//		dp[i]=max(dp[i],-X+min(dp[j]+pre[j],2*X-2*pre[j+1]));
//		for(int j=1;j<i;j+=2)dp[i]=max(dp[i],-X+min(A[j],2*X+B[j]));
		dp[i]=max(dp[i],int(-X+max(yxg1.query(2*X),2*X+yxg2.query(-2*X-1))));
		A[i]=dp[i]+pre[i];
		B[i]=-2*pre[i+1];
		yxg1.add(A[i]-B[i],A[i]);
		yxg2.add(B[i]-A[i],B[i]);
	}
	
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(i&1?a[i]:-a[i]);
	if(n%2==0)
	{
		out(max(pre[n],-pre[n]));
		return 0;
	}
	int ans=pre[n];
	int sum=cost(1,n);
	calcdp(dp0);
	reverse(a+1,a+n+1);
	calcdp(dp1);
	reverse(a+1,a+n+1);
	reverse(dp1+1,dp1+n+1);
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(i&1?a[i]:-a[i]);
//	for(int i=1;i<=n;i+=2)cerr<<dp0[i]<<" ";cerr<<endl;
//	for(int i=1;i<=n;i+=2)cerr<<dp1[i]<<" ";cerr<<endl;
	
	for(int i=2;i<=n;i+=2)
	{
		ans=max(ans,min(dp0[i-1]-cost(i,n),dp1[i+1]-cost(1,i)));
	}
	out(ans);
	return 0;
}

Measured memory_bytes: 25472