#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ind_left = 0, ind_right, serj = 0, dima = 0;
  cin >> n;
  int arr[n];
  for (int a = 0; a < n; a++) cin >> arr[a];
  ind_right = n;
  for (int j = 0; j < n; j++) {
    if (j % 2 == 0) {
      if (arr[ind_left] >= arr[ind_right - 1]) {
        serj += arr[ind_left];
        ++ind_left;
      } else if (arr[ind_right - 1] > arr[ind_left]) {
        serj += arr[ind_right - 1];
        --ind_right;
      }
    }
    if (j % 2 == 1) {
      if (arr[ind_left] >= arr[ind_right - 1]) {
        dima += arr[ind_left];
        ++ind_left;
      } else if (arr[ind_right - 1] > arr[ind_left]) {
        dima += arr[ind_right - 1];
        --ind_right;
      }
    }
  }
  cout << serj << "  " << dima;
}
