#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sereja_score = 0, Dima_score = 0;
  bool p = true;
  cin >> n;
  int l = 0, r = n - 1;
  int cards[n];
  for (int i = 0; i < n; i++) {
    cin >> cards[i];
  }
  while (r >= l) {
    if (cards[l] >= cards[r]) {
      if (p)
        sereja_score += cards[l];
      else
        Dima_score += cards[l];
      l++;
    } else if (cards[r] >= cards[l]) {
      if (p)
        sereja_score += cards[r];
      else
        Dima_score += cards[r];
      r--;
    }
    if (p)
      p = false;
    else
      p = true;
  }
  cout << sereja_score << " " << Dima_score;
  return 0;
}
