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