#include <bits/stdc++.h>
int caseno = 1;
using namespace std;
int main() {
  int n, x, dm = 0, sj = 0;
  deque<int> DQ;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    DQ.push_back(x);
  }
  bool f = false;
  while (!DQ.empty()) {
    if (DQ.front() > DQ.back()) {
      x = DQ.front();
      DQ.pop_front();
    } else {
      x = DQ.back();
      DQ.pop_back();
    }
    if (!f)
      sj += x;
    else
      dm += x;
    f = !f;
  }
  printf("%d %d\n", sj, dm);
  return 0;
}
