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