#include <bits/stdc++.h>
using namespace std;
int main() {
  deque<int> dq;
  int n;
  cin >> n;
  int f = 0, a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    dq.push_back(x);
  }
  while (!dq.empty()) {
    int ans = max(dq.front(), dq.back());
    if (f == 0) {
      a += ans;
      f = 1;
      if (ans == dq.front())
        dq.pop_front();
      else
        dq.pop_back();
    } else {
      b += ans;
      f = 0;
      if (ans == dq.front())
        dq.pop_front();
      else
        dq.pop_back();
    }
  }
  cout << a << " " << b;
  return 0;
}
