#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int sum = 0;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	int diff = 0;
	for(int i = 0; i < n; i++){
		if(i % 2){
			diff -= a[i];
		} else {
			diff += a[i];
		}
	}
	if(n % 2 == 0){
		cout << (sum + max(diff, -diff)) / 2 << " " << (sum - max(diff, -diff)) / 2 << '\n';
		return 0;
	}
	if(diff >= 1000){
		cout << (sum + diff) / 2 << " " << (sum - diff) / 2 << '\n';
		return 0;
	}
	int s = 0;
	int e = 1000;
	while(s + 1 < e){
		int d = (s + e) / 2;
		vector<int> r;
		r.push_back(a[0]);
		for(int i = 1; i < n; i += 2){
			if(r[r.size() - 1] < d || a[i] <= r[r.size() - 1]){
				r[r.size() - 1] += a[i+1] - a[i];
			} else {
				r.push_back(a[i]);
				r.push_back(a[i+1]);
			}
		}
		if(r[r.size() - 1] >= d){
			s = d;
		} else {
			e = d;
		}
	}
	cout << (sum + max(diff, (-diff + 2 * s))) / 2 << " " << (sum - max(diff, (-diff + 2 * s))) / 2 << '\n';
	return 0;
}