#include <bits/stdc++.h>
using namespace std;
void funtion(vector<int> v, int n) {
  int i = 0, j = n - 1;
  int s = 0, d = 0, turn = 0;
  while (i <= j) {
    if (turn % 2 == 0) {
      if (v[i] >= v[j])
        s += v[i++];
      else
        s += v[j--];
    } else {
      if (v[i] >= v[j])
        d += v[i++];
      else
        d += v[j--];
    }
    turn++;
  }
  cout << s << " " << d;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  funtion(v, n);
  return 0;
}
