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

const int MN = 300010;

int N, B, W;
int A[MN], psum[MN];

bool check(int x) {
    int mx = psum[N - 1];
    for(int i = N - 1; i >= 0; i--) {
        if(i % 2 && mx - psum[i] >= x) {
            mx = max(mx, psum[i] + A[i]);
        }
    }
    return mx >= x;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        if(i % 2) W += A[i];
        else B += A[i];
    }

    if(N % 2 == 0) {
        printf("%d %d", max(B, W), min(B, W));
        return 0;
    }

    for(int i = 0; i < N; i++) {
        if(i % 2) psum[i] = -A[i];
        else psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    int s = 0, e = 1e9, p = -1;
    while(s <= e) {
        int m = (s + e)>>1;

        if(check(m)) {
            p = m;
            s = m + 1;
        }
        else e = m - 1;
    }
    printf("%d %d", W + p, B - p);
}
