#include <bits/stdc++.h>
using namespace std;
int GLL(long long& x) { return scanf("%lld", &x); }
int GI(int& x) { return scanf("%d", &x); }
const int MAXN = 55;
int value[MAXN], suffix[MAXN], dp[MAXN];
int n;
int rec(int i) {
  if (dp[i] != -1) return dp[i];
  dp[i] = max(rec(i + 1), value[i] + suffix[i + 1] - rec(i + 1));
  return dp[i];
}
int main() {
  GI(n);
  int tot = 0;
  for (int i = 0; i < (int)(n); i++) {
    GI(value[i]);
    tot += value[i];
  }
  memset(suffix, 0, sizeof suffix);
  for (int i = (int)(n)-1; i >= 0; i--) {
    suffix[i] = suffix[i + 1] + value[i];
  }
  memset(dp, -1, sizeof dp);
  dp[n - 1] = value[n - 1];
  int b = rec(0);
  cout << tot - b << " " << b << "\n";
  return 0;
}
