#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int s = 0, d = 0;
  int turn = 1;
  int i = 0, j = n - 1, k = 0, ind = -1;
  while (k < n) {
    int max = 0;
    if (a[i] > a[j]) {
      max = a[i];
      ind = i;
    } else {
      max = a[j];
      ind = j;
    }
    if (turn == 1) {
      s += max;
      turn = 0;
    } else {
      d += max;
      turn = 1;
    }
    if (ind == i)
      i++;
    else
      j--;
    k++;
  }
  cout << s << " " << d << endl;
  return 0;
}
