#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> card;
  for (int i = 0; i < n; ++i) {
    int num;
    cin >> num;
    card.push_back(num);
  }
  int s = 0, d = 0;
  bool sereja = true;
  while (!card.empty()) {
    if (*(card.begin()) > *(card.rbegin())) {
      if (sereja) {
        s += *(card.begin());
        card.erase(card.begin());
        sereja = !sereja;
      } else {
        d += *(card.begin());
        card.erase(card.begin());
        sereja = !sereja;
      }
    } else {
      if (sereja) {
        s += *(card.rbegin());
        card.pop_back();
        sereja = !sereja;
      } else {
        d += *(card.rbegin());
        card.pop_back();
        sereja = !sereja;
      }
    }
  }
  cout << s << " " << d;
  return 0;
}
