#include <bits/stdc++.h>
using namespace std;
int n;
bool flag = true;
int main() {
  cin >> n;
  int arr[n], lptr = 0, rptr = n - 1, s = 0, d = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  while (n-- > 0) {
    if (arr[lptr] > arr[rptr]) {
      (flag) ? s += arr[lptr++] : d += arr[lptr++];
      flag = !flag;
    } else {
      (flag) ? s += arr[rptr--] : d += arr[rptr--];
      flag = !flag;
    }
  }
  cout << s << " " << d << endl;
  return 0;
}
