#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 55;
int x[MAX];
int s[2];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  int i = 0;
  int l = 0, r = n - 1;
  while (l <= r) {
    if (x[l] > x[r]) {
      s[i % 2] += x[l];
      l++;
    } else {
      s[i % 2] += x[r];
      r--;
    }
    i++;
  }
  cout << s[0] << " " << s[1];
  return 0;
}
