#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int main() {
  int i, j, k, n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int a, b;
  for (a = b = i = j = 0, k = n - i - 1; i <= k;) {
    if (j == 0) {
      if (arr[i] > arr[k]) {
        a += arr[i];
        j = 1;
        i++;
      } else {
        a += arr[k];
        j = 1;
        k--;
      }
    } else {
      if (arr[i] > arr[k]) {
        b += arr[i];
        j = 0;
        i++;
      } else {
        b += arr[k];
        j = 0;
        k--;
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}
