#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=300000;

int n;
int a[MAXN];

int sumodd,sumevn;

bool can(int want) {
	if(want<sumodd) return true;
	int need=want-sumodd;
	int cur=0;
	for(int i=0;i<n;i+=2) {
		if(i>0) { if(cur>=need&&cur-a[i-1]<0) cur=0; else cur-=a[i-1]; }
		cur+=a[i];
	}
	return cur>=need;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);

	sumodd=0,sumevn=0; REP(i,n) if(i%2==0) sumevn+=a[i]; else sumodd+=a[i];
	if(n%2==0) {
		printf("%d %d\n",max(sumodd,sumevn),min(sumodd,sumevn));
	} else {
		int l=max(sumodd,sumevn),h=sumodd+sumevn+1;
		while(l+1<h) {
			int m=l+(h-l)/2;
			if(can(m)) l=m; else h=m;
		}
		printf("%d %d\n",l,sumodd+sumevn-l);
	}
}

int main() {
	run();
	return 0;
}
