#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s = 0, l = 0, r, d = 0, b = 0;
  cin >> n;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  r = n - 1;
  while (r >= l) {
    if (b % 2 == 0) {
      if (v[l] >= v[r]) {
        s += v[l];
        l++;
      } else {
        s += v[r];
        r--;
      }
    } else {
      if (v[l] >= v[r]) {
        d += v[l];
        l++;
      } else {
        d += v[r];
        r--;
      }
    }
    b++;
  }
  cout << s << " " << d;
  return 0;
}
