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