#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> a;
  int temp = 0, sumb = 0, sumc = 0;
  for (int i = 0; i < t; i++) {
    cin >> temp;
    a.push_back(temp);
  }
  for (int i = 0; i < t; i++) {
    int tem = 0;
    if (a[0] < a[a.size() - 1]) {
      tem = a[a.size() - 1];
      a.erase(a.end() - 1);
    } else if (a[0] > a[a.size() - 1]) {
      tem = a[0];
      a.erase(a.begin() + 0);
    }
    if (i % 2 == 0)
      sumb += tem;
    else
      sumc += tem;
  }
  if (t % 2 != 0)
    cout << sumb + a[0] << " " << sumc << endl;
  else
    cout << sumb << " " << sumc + a[0] << endl;
}
