#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=3e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],sb=0,sw=0;
int check(int mid) {
    int val=a[1];
    for(int i=3;i<=n;i+=2) {
        if(val>=mid) val=max(val+a[i]-a[i-1],a[i]);
        else val+=a[i]-a[i-1];
    }
    return val>=mid;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi(),(i&1)?sb+=a[i]:sw+=a[i];
    if(!(n&1)) return printf("%d %d\n",max(sb,sw),min(sb,sw)),0;
    int l=0,r=sb,ret=0;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) ret=mid,l=mid+1;
        else r=mid-1;
    }
    printf("%d %d\n",sw+ret,sb-ret);
    return 0;
}
