#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum1 = 0, sum2 = 0;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int i = 0;
  int ar[2] = {0, 0}, p = 0, r = n - 1;
  while (i <= r) {
    if (arr[i] >= arr[r]) {
      ar[p] += arr[i];
      i++;
    } else {
      ar[p] += arr[r];
      r--;
    }
    p++;
    p %= 2;
  }
  cout << ar[0] << " " << ar[1];
  return 0;
}
