#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int n, h, a[2] = {0};
  bool b = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h);
    v.push_back(h);
  }
  while (v.size() != 0) {
    int f = v[0], l = v[v.size() - 1];
    b = !b;
    if (f >= l) {
      a[b] += f;
      v.erase(v.begin());
    } else {
      a[b] += l;
      v.pop_back();
    }
  }
  printf("%d %d\n", a[0], a[1]);
  return 0;
}
