#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    nums.push_back(x);
  }
  int first = 0;
  int last = n - 1;
  int sereja = 0;
  int duma = 0;
  bool isSereja = true;
  while (n) {
    int largest;
    if (nums[first] > nums[last]) {
      largest = nums[first];
      first++;
    } else {
      largest = nums[last];
      last--;
    }
    if (isSereja) {
      sereja += largest;
    } else {
      duma += largest;
    }
    n--;
    isSereja = !isSereja;
  }
  cout << sereja << ' ' << duma << endl;
  return 0;
}
