#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sumserja = 0, sumdima = 0;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  bool p = true;
  int l = 0, r = n - 1;
  while (l <= r) {
    if (arr[l] >= arr[r]) {
      if (p) {
        sumserja += arr[l];
        l++;
      } else {
        sumdima += arr[l];
        l++;
      }
    } else if (arr[r] >= arr[l]) {
      if (p) {
        sumserja += arr[r];
        r--;
      } else {
        sumdima += arr[r];
        r--;
      }
    }
    if (p == true) {
      p = false;
    } else {
      p = true;
    }
  }
  cout << sumserja << " " << sumdima << endl;
  return 0;
}
