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