#include <bits/stdc++.h>
using namespace std;
int main() {
  deque<int> q;
  int n, i, t;
  unsigned long int sereja = 0, dima = 0;
  bool se = true;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t;
    q.push_back(t);
  }
  for (i = 0; i < n; i++) {
    if (q.front() > q.back()) {
      t = q.front();
      q.pop_front();
    } else {
      t = q.back();
      q.pop_back();
    }
    if (se) {
      sereja += t;
      se = false;
    } else {
      dima += t;
      se = true;
    }
  }
  cout << sereja << ' ' << dima << endl;
}
