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