#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, sere = 0, dima = 0, t = 1;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int i = 0, j = n - 1;
  while (i != j) {
    if (v[i] > v[j]) {
      if (t % 2 != 0)
        sere = sere + v[i];
      else
        dima = dima + v[i];
      i++;
    } else {
      if (t % 2 != 0)
        sere = sere + v[j];
      else
        dima = dima + v[j];
      j--;
    }
    t++;
  }
  if (n % 2 == 0)
    dima = dima + v[j];
  else
    sere = sere + v[i];
  cout << sere << " " << dima << endl;
}
