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