#include <bits/stdc++.h>
using namespace std;
const int inf = 0;
const double eps = 0;
const int ms = 0;
const int md = 0;
int dp[55][2];
int n, x;
vector<int> v, sum;
int calc(int pos, int x) {
  if (pos == n - 1) return v[pos];
  int &ret = dp[pos][x];
  if (ret != -1) return ret;
  ret =
      max(v[pos] + sum[pos + 1] - calc(pos + 1, (x + 1) % 2), calc(pos + 1, x));
  return ret;
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sum.push_back(0);
  for (int i = 0; i < n; i++) {
    sum.push_back(sum[i] + v[n - i - 1]);
  }
  reverse((sum).begin(), (sum).end());
  int res = calc(0, 0);
  cout << sum[0] - res << " " << res;
}
