#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vec, suf, win;
int main() {
  cin >> n;
  vec.resize(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  suf.resize(n, 0);
  suf[n - 1] = vec[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    suf[i] = suf[i + 1] + vec[i];
  }
  win.resize(n + 1, 0);
  win[n] = 0;
  win[n - 1] = vec[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    int w = suf[i] - win[i + 1];
    for (int j = i + 1; j < n; j++) {
      w = max(w, suf[j] - win[j + 1]);
    }
    win[i] = w;
  }
  cout << suf[0] - win[0] << " " << win[0];
  return 0;
}
