#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s1 = 0, s2 = 0, sum = 0;
  cin >> n;
  vector<int> a(n);
  for (auto &it : a) cin >> it;
  for (int i = 0; i < n; i++) {
    int k = a[a.size() - 1];
    int m = a[0];
    if (k >= m) {
      if (i % 2 != 0)
        s2 += k;
      else
        s1 += k;
      a.erase(a.begin() + (a.size() - 1));
    } else if (m > k) {
      if (i % 2 == 0)
        s1 += m;
      else
        s2 += m;
      a.erase(a.begin());
    }
  }
  cout << s1 << " " << s2 << endl;
  return 0;
}
