
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

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

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 300500;
int sum[N], a[N], res, t, n;
bool check(int mid) {
    int k = 0;
    for (int i = 2;i <= n; i += 2) 
        if (sum[i-1] - k >= mid) Mn(k, sum[i]);
    return sum[n] - k >= mid;
}

int main() {
    read(n);
    for (int i = 1;i <= n; i++) {
        read(a[i]), sum[i] = i & 1 ? sum[i-1] + a[i] : sum[i-1] - a[i];
        res += a[i];
    }
    if (~n & 1) {
        t = max(sum[n], -sum[n]);
        write((res + t) / 2, ' '), write((res - t) / 2);
        return 0;
    }
    int l = 0, r = 1e9;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) l = mid + 1;
        else r = mid - 1;
    }
    t  = -sum[n] + 2 * r;
    write((res + t) / 2, ' '), write((res - t) / 2, ' ');
    return 0;
}