#include <bits/stdc++.h>
using namespace std;
long long n, k, a[100000], cnta = 0, cntb = 0, cnt = 0, b, be, ended;
bool re = false;
inline long long pow(long long n) {
  if (n == 0) return 1;
  long long t = pow(n / 2) % 10;
  if (n % 2 == 0) return t * t % 10;
  return t * t * 1378 % 10;
}
inline void doing() {
  cin >> n;
  ended = n - 1;
  be = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (be <= ended) {
    if (!re) {
      cnta += max(a[be], a[ended]);
      re = true;
    } else {
      cntb += max(a[be], a[ended]);
      re = false;
    }
    if (a[be] <= a[ended])
      ended--;
    else
      be++;
  }
  cout << cnta << " " << cntb;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  doing();
}
