#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int b = 0, c = 0;
  int cnt = 0;
  int l = 0, r = n - 1;
  while (cnt < n) {
    if (cnt % 2 == 0) {
      if (a[l] < a[r])
        b += a[r], r--;
      else
        b += a[l], l++;
    } else {
      if (a[l] < a[r])
        c += a[r], r--;
      else
        c += a[l], l++;
    }
    cnt++;
  }
  cout << b << " " << c << endl;
  return 0;
}
