#include<bits/stdc++.h>
using namespace std;
#define M 300005
int read() {
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
	    if(ch=='-') w=-1;
	    ch=getchar();
	}
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return s*w;
}
int n,a[M],sum;
int s[M],a1,a2;
bool check(int lim) {
    int p=0;
    for(int i=1;i<=n+1;i++)
	{
	    if(i&1) continue ;
	    if(s[i-1]-s[p]>=lim)
		{
		    if(i==n+1) return 1;
		    if(s[i]<s[p]) p=i;
		}
	}
    return 0;
}
void work() {
    for(int i=1;i<=n;i++) s[i]=s[i-1]+(i&1?a[i]:-a[i]);
    for(int i=2;i<=n;i+=2) a1+=a[i];
    int l=-sum,r=sum,mid,ans;
    do{
	mid=(l+r)>>1;
	if(check(mid)) ans=mid,l=mid+1;
	else r=mid-1;
    }while(l<=r);
    a1+=ans,a2=sum-a1;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++) {a[i]=read();sum+=a[i];}
    if(!(n&1))
	{
	    int x=0;
	    for(int i=1;i<=n;i+=2) x+=a[i];
	    if(x>a1) a1=x,a2=sum-x;
	    x=0;
	    for(int i=n;i>=1;i-=2) x+=a[i];
	    if(x>a1) a1=x,a2=sum-x;
	}
    else work();
    cout<<a1<<' '<<a2<<'\n';
    return 0;
}