#include <bits/stdc++.h>
using namespace std;

const int N = 300010;

int num[N], sum[N], n;

int main() {
    scanf("%d", &n); int A = 0, B = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &num[i]), sum[i] = sum[i - 1];
        if (i & 1) sum[i] += num[i], A += num[i];
        else sum[i] -= num[i], B += num[i];
    }
    if (n % 2 == 0) {
        printf("%d %d\n", max(A, B), min(A, B));
        return 0;
    }
    auto check = [&](int mid) -> bool {
        int mn = 0; static int dp[N];
        for (int i = 1; i <= n; i += 2) 
            if (sum[i] - mn >= mid) {
                mn = min(mn, sum[i + 1]), dp[i] = 1;
            } else dp[i] = 0;
        return dp[n];
    };
    int l = 1, r = A + B, mid, res = B;
    while (l <= r) {
        if (check(mid = (l + r) >> 1)) res = B + mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%d %d\n", res, A + B - res);
} 