#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt1 = 0, cnt2 = 0;
  cin >> n;
  int arr[1010];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int round = 1, i = 0, j = n - 1;
  while (round <= n) {
    if (round % 2 == 1)
      cnt1 += max(arr[i], arr[j]);
    else
      cnt2 += max(arr[i], arr[j]);
    if (arr[i] >= arr[j])
      i++;
    else
      j--;
    round++;
  }
  cout << cnt1 << " " << cnt2;
  return 0;
}
