#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp, temp_for_vec, serge_total = 0, dema_total = 0;
  cin >> n;
  temp = n;
  vector<int> v;
  while (temp--) {
    cin >> temp_for_vec;
    v.push_back(temp_for_vec);
  }
  vector<int>::iterator it_begin;
  int it_end;
  while (v.size() != 0) {
    it_begin = v.begin();
    it_end = v.back();
    if (*it_begin >= it_end) {
      serge_total += *it_begin;
      v.erase(v.begin());
    } else {
      serge_total += it_end;
      v.pop_back();
    }
    if (v.size() == 0) break;
    it_begin = v.begin();
    it_end = v.back();
    if (*it_begin >= it_end) {
      dema_total += *it_begin;
      v.erase(v.begin());
    } else {
      dema_total += it_end;
      v.pop_back();
    }
  }
  cout << serge_total << " " << dema_total;
  return 0;
}
