#include <bits/stdc++.h>
using namespace std;
int card[10010];
int main() {
  int n, r, s = 0, d = 0, l = 1, num = 0;
  cin >> n;
  r = n;
  for (int i = 1; i <= n; i++) {
    cin >> card[i];
  }
  while (l <= r) {
    num++;
    if (num & 1) {
      if (card[l] > card[r]) {
        s += card[l];
        l++;
      } else {
        s += card[r];
        r--;
      }
    } else {
      if (card[l] > card[r]) {
        d += card[l];
        l++;
      } else {
        d += card[r];
        r--;
      }
    }
  }
  cout << s << " " << d << endl;
}
