#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 5);
const int mod = int(1e9);
const double eps = 1e-9;
const double pi = 3.1415926535897932384626433832795;
int a[N];
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ans[2];
  ans[0] = ans[1] = 0;
  for (int l = 0, r = n - 1, p = 0; l <= r; p ^= 1) {
    if (a[l] > a[r]) {
      ans[p] += a[l++];
    } else {
      ans[p] += a[r--];
    }
  }
  printf("%d %d\n", ans[0], ans[1]);
}
int main() {
  int tests = 1;
  while (tests--) {
    solve();
  }
  return 0;
}
