#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int s = 0;
  int d = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = 0;
  int count = 1;
  int beg = 0;
  int last = n - 1;
  while (count <= n) {
    if (i == 0) {
      if (a[beg] > a[last]) {
        s = s + a[beg];
        beg++;
        i = 1;
      } else {
        s = s + a[last];
        last--;
        i = 1;
      }
    } else {
      if (a[beg] > a[last]) {
        d = d + a[beg];
        beg++;
        i = 0;
      } else {
        d = d + a[last];
        last--;
        i = 0;
      }
    }
    count++;
  }
  cout << s << " " << d;
  return 0;
}
