#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int left = 0;
  int right = n - 1;
  int flag = 0;
  int s = 0;
  int d = 0;
  while (left <= right) {
    int sum = 0;
    if (a[left] >= a[right]) {
      sum = a[left];
      left++;
    } else {
      sum = a[right];
      right--;
    }
    if (flag == 0) {
      s += sum;
      flag = 1;
    } else {
      d += sum;
      flag = 0;
    }
  }
  cout << s << " " << d << endl;
}
