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