#include <bits/stdc++.h>

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = (int) 3e5;

int n;
int ans[2], a[N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    for(int i = 1; i <= n; ++i) {
        read(a[i]), ans[i & 1] += a[i];
    }

    if(n & 1) {
        int l = 0, r = ans[0];

        while(l < r) {
            int mid = (l + r + 1) >> 1, cur = 0, lst = 0;
            for(int i = 1; i <= n; ++i) {
                if(!(i & 1)) {
                    if(ans[0] + cur - lst >= ans[1] + mid) {  
                        chkmin(lst, cur - a[i]);
                    }
                }
                cur += (i & 1) ? a[i] : -a[i];
            }

            if(ans[0] + cur - lst >= ans[1] + mid) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }
        printf("%d %d\n", ans[1] + l, ans[0] - l);
    } else {
        if(ans[0] < ans[1])
            std::swap(ans[0], ans[1]);
        printf("%d %d\n", ans[0], ans[1]);
    }

    return 0;
}
