#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n % 2 == 0) {
        int s1 = 0;
        int s2 = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                s1 += a[i];
            } else {
                s2 += a[i];
            }
        }
        cout << std::max(s1, s2) << " " << std::min(s1, s2) << "\n";
        return 0;
    }

    int l = 0;
    int r = 1000000000;
    while (r > l + 1) {
        int m = (l + r) / 2;
        int bp = 0;
        int s = 0;
        bool ok = false;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                s += a[i];
                if (s - bp >= m) {
                    if (i == n - 1) {
                        ok = true;
                    } else {
                        if (s - a[i + 1] < bp) {
                            bp = s - a[i + 1];
                        }
                    }
                }
            } else {
                s -= a[i];
            }
        }
        if (ok) {
            l = m;
        } else {
            r = m;
        }
    }

    int s = l;
    int s2 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) s += a[i];
        s2 += a[i];
    }
    cout << s << " " << s2 - s << "\n";

    return 0;
}