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