#include <bits/stdc++.h>
using namespace std;
deque<int> q;
int main() {
  int n;
  cin >> n;
  for (int i = 0, x; i < n; ++i) cin >> x, q.push_back(x);
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; ++i) {
    int& tmp = i % 2 ? ans2 : ans1;
    q.front() > q.back() ? (tmp += q.front(), q.pop_front())
                         : (tmp += q.back(), q.pop_back());
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
