#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, sum1 = 0;
  bool a = false, b = false;
  cin >> n;
  deque<int> d;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    d.push_back(l);
  }
  while (d.size() != 0) {
    sum += max(d.front(), d.back());
    if (max(d.front(), d.back()) == d.front()) {
      d.pop_front();
    } else {
      d.pop_back();
    }
    if (d.size() == 0) {
      break;
    }
    sum1 += max(d.front(), d.back());
    if (max(d.front(), d.back()) == d.front()) {
      d.pop_front();
    } else {
      d.pop_back();
    }
  }
  cout << sum << " " << sum1;
}
