#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 2;
int card[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, turn = 0, srj = 0, dim = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> card[i];
  int ptrr = n - 1, ptrl = 0;
  while (ptrr >= ptrl) {
    if (turn == 0) {
      if (card[ptrr] > card[ptrl]) {
        srj += card[ptrr];
        ptrr--;
        turn = 1;
      } else {
        srj += card[ptrl];
        ptrl++;
        turn = 1;
      }
    } else {
      if (card[ptrr] > card[ptrl]) {
        dim += card[ptrr];
        ptrr--;
      } else {
        dim += card[ptrl];
        ptrl++;
      }
      turn = 0;
    }
  }
  cout << srj << " " << dim << endl;
  return 0;
}
