#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, pointerleft = 1, pointerright, dd = 0, db = 0;
  cin >> n;
  pointerright = n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[pointerright] > a[pointerleft]) {
      if (i % 2 == 1) {
        dd += a[pointerright];
        pointerright--;
      } else {
        db += a[pointerright];
        pointerright--;
      }
    } else {
      if (i % 2 == 1) {
        dd += a[pointerleft];
        pointerleft++;
      } else {
        db += a[pointerleft];
        pointerleft++;
      }
    }
  }
  cout << dd << " " << db << endl;
}
