#include <iostream>
#include <vector>
using namespace std;

int N;
vector<long long> a;

int main() {
    cin >> N;
    long long black = 0, white = 0;
    a.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (i % 2 == 0) black += a[i];
        else white += a[i];
    }
    if (N % 2 == 0) cout << max(black, white) << " " << min(black, white) << endl;
    else {
        long long low = 0, high = 1<<30;
        while (high - low > 1) {
            long long mid = (low + high) / 2;
			vector<long long> dp; dp.assign(N + 1, -(1LL << 60));
			dp[1] = a[0];
			for (int i = 3; i <= N; i += 2) {
				// 直前をカットする場合
				if (dp[i - 2] >= mid) dp[i] = max(dp[i], a[i - 1]);
				
				// 直前をカットしない場合
				dp[i] = max(dp[i], dp[i - 2] - a[i - 2] + a[i - 1]);
			}
			if (dp[N] >= mid) low = mid;
			else high = mid;
        }
        cout << white + low << " " << black - low << endl;
    }
}
