#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    v.emplace_back(a);
  }
  int S = 0;
  int D = 0;
  int i = v.begin() - v.begin();
  int j = v.end() - v.begin() - 1;
  int chance = 0;
  for (int ii = i, jj = j; jj >= ii; chance++) {
    int score = max(v[ii], v[jj]);
    if (chance % 2 == 0) {
      S += score;
    } else
      D += score;
    if (v[ii] > v[jj]) {
      ii++;
    } else
      jj--;
  }
  cout << S << " " << D;
}
