#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  long long int left = 0;
  long long int right = n - 1;
  long long int ptseer = 0, ptdima = 0;
  long long int turn = 1;
  while (left <= right) {
    if (turn % 2 != 0) {
      if (v[right] > v[left]) {
        ptseer += v[right];
        right--;
      } else {
        ptseer += v[left];
        left++;
      }
      turn++;
    } else {
      if (v[right] > v[left]) {
        ptdima += v[right];
        right--;
      } else {
        ptdima += v[left];
        left++;
      }
      turn++;
    }
  }
  cout << ptseer << " " << ptdima << "\n";
  return 0;
}
