#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const int maxn = 100 * 1000 + 9;
vector<int> g[maxn];
int arr[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  int sum1 = 0, sum2 = 0;
  int l = 1, r = n;
  int status = 0;
  while (l <= r) {
    if (arr[l] > arr[r]) {
      if (status == 0) {
        sum1 += arr[l];
      } else {
        sum2 += arr[l];
      }
      status = 1 - status;
      l++;
    } else {
      if (status == 0) {
        sum1 += arr[r];
      } else {
        sum2 += arr[r];
      }
      status = 1 - status;
      r--;
    }
  }
  printf("%d %d\n", sum1, sum2);
  return 0;
}
