#include <bits/stdc++.h>
using namespace std;
const int F = 10000;
int a[F];
int main() {
  int sd[2] = {0}, j, k, n;
  cin >> n;
  j = 0, k = n - 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[j] > a[k])
      sd[i % 2] += a[j++];
    else
      sd[i % 2] += a[k--];
  }
  cout << sd[0] << " " << sd[1];
  return 0;
}
