#include <bits/stdc++.h>
using namespace std;
int n, ans[2];
vector<int> v;
bool turn = false;
int main() {
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  while (v.size() != 0) {
    if (v[0] > v[v.size() - 1]) {
      ans[turn] += v[0];
      v.erase(v.begin());
    } else {
      ans[turn] += v[v.size() - 1];
      v.erase(v.begin() + v.size() - 1);
    }
    turn = !turn;
  }
  cout << ans[0] << " " << ans[1];
  return 0;
}
