#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, s = 0, d = 0, *p;
  deque<int> q;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push_back(a);
  }
  p = &s;
  while (!q.empty()) {
    if (q.front() > q.back()) {
      *p += q.front();
      q.pop_front();
    } else {
      *p += q.back();
      q.pop_back();
    }
    p = p == &s ? &d : &s;
  }
  cout << s << " " << d << endl;
}
