#include <bits/stdc++.h>
using namespace std;
int main() {
  int siz = 0;
  cin >> siz;
  vector<int> l;
  int sC = 0, dC = 0;
  for (int x = 0; x < siz; x++) {
    int dummy;
    cin >> dummy;
    l.push_back(dummy);
  }
  for (int i = 0; i < siz; i++) {
    int maxNumber = 0;
    if (*(l.end() - 1) >= *l.begin()) {
      maxNumber = *(l.end() - 1);
      l.pop_back();
    } else {
      maxNumber = *l.begin();
      l.erase(l.begin());
    }
    (i % 2 == 0) ? sC += maxNumber : dC += maxNumber;
  }
  cout << sC << " " << dC;
  return 0;
}
