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