#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int sums = 0;
  int sumd = 0;
  bool turns = true;
  int l = 0, r = n - 1;
  while (l <= r) {
    if (turns) {
      sums += max(arr[l], arr[r]);
      turns = false;
      arr[l] > arr[r] ? l++ : r--;
    } else {
      sumd += max(arr[l], arr[r]);
      turns = true;
      arr[l] > arr[r] ? l++ : r--;
    }
  }
  cout << sums << " " << sumd << endl;
  return 0;
}
