#include <bits/stdc++.h>
using namespace std;
int main() {
  int numOfCards;
  cin >> numOfCards;
  int arr[numOfCards];
  for (int i = 0; i < numOfCards; i++) {
    cin >> arr[i];
  }
  int s = 0, d = 0, left = 0, right = numOfCards - 1, turn = 0;
  for (int i = 0; i < numOfCards; i++) {
    if (turn % 2 == 0) {
      if (arr[left] > arr[right]) {
        s += arr[left];
        left++;
      } else {
        s += arr[right];
        right--;
      }
    } else {
      if (arr[left] > arr[right]) {
        d += arr[left];
        left++;
      } else {
        d += arr[right];
        right--;
      }
    }
    turn--;
  }
  cout << s << endl;
  cout << d;
  return 0;
}
