#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 5;
int n;
int a[maxn], sum[maxn], w[2];
pair<int, int> dp[maxn];
pair<int, int> dfs(int now, int op) {
  if (now > n) return make_pair(0, 0);
  if (now == n) return dp[now] = make_pair(a[n], 0);
  pair<int, int> ret = make_pair(0, 0);
  if (dp[now] != make_pair(0, 0)) return dp[now];
  if (now == n - 1) {
    return dp[n - 1] = make_pair(max(a[n - 1], a[n]), min(a[n - 1], a[n]));
  } else {
    pair<int, int> cur = make_pair(0, 0);
    cur.first += a[now], cur.second = 0;
    pair<int, int> nxt = dfs(now + 1, op ^ 1);
    cur.first += nxt.second, cur.second += nxt.first;
    ret = max(ret, cur);
    for (int i = now; i <= n - 1; i++) {
      cur = make_pair(0, 0);
      cur.second += sum[i] - sum[now - 1];
      cur.first += a[i + 1];
      nxt = dfs(i + 2, op ^ 1);
      cur.first += nxt.second;
      cur.second += nxt.first;
      ret = max(ret, cur);
    }
    return dp[now] = ret;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  pair<int, int> res = dfs(1, 0);
  printf("%d %d\n", res.second, res.first);
  return 0;
}
