#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int s = 0, d = 0;
  int i = 0, j = n - 1;
  bool f = true;
  while (i <= j) {
    if (v[i] > v[j]) {
      if (f) {
        s += v[i];
        f = false;
      } else {
        d += v[i];
        f = true;
      }
      i++;
    } else {
      if (f) {
        s += v[j];
        f = false;
      } else {
        d += v[j];
        f = true;
      }
      j--;
    }
  }
  cout << s << " " << d << endl;
  return 0;
}
