#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, scores[1009], start = 0, end, sereja = 0, dima = 0, hold;
  cin >> n;
  end = n - 1;
  for (int i = 0; i < n; i++) {
    cin >> scores[i];
  }
  for (int i = 0; start <= end; i++) {
    hold = max(scores[start], scores[end]);
    if (hold == scores[start]) {
      if (i % 2 == 0)
        sereja += hold;
      else
        dima += hold;
      start++;
    } else {
      if (i % 2 == 0)
        sereja += hold;
      else
        dima += hold;
      end--;
    }
  }
  cout << sereja << " " << dima << endl;
  return 0;
}
