#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 1000;
int n,a[N],sum[N],s[2];
int check(int x)
{
	int k = 0;
	for(int i = 2;i <= n;i += 2)
		if(sum[i - 1] - k >= x) k = min(sum[i],k); 
	return sum[n] - k >= x;
}
signed main()
{
	n = read();
	for(int i = 1;i <= n;i ++) s[i & 1] += (a[i] = read());
	if((n & 1) == 0) {cout << max(s[0],s[1]) << " " << min(s[0],s[1]); return 0;}
	else
	{
		for(int i = 1;i <= n;i ++) sum[i] = sum[i - 1] + (i & 1 ? a[i] : -a[i]);
		int l = 0,r = s[0] + s[1],mid,ans = 0;
		while(l <= r)
		{
			mid = (l + r) >> 1;
			if(check(mid)) {ans = mid; l = mid + 1;}
			else r = mid - 1;
		}
		cout << s[0] + ans << " " << s[1] - ans;
	}
}