#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s1 = 0, s2 = 0, mx, a[10000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0, c = 1; i < n; c++) {
    if (c % 2 != 0) {
      int sz = n - 1;
      if (a[i] > a[sz]) {
        s1 += a[i];
        i++;
      } else {
        s1 += a[sz];
        n--;
      }
    } else {
      int s = n - 1;
      if (a[i] > a[s]) {
        s2 += a[i];
        i++;
      } else {
        s2 += a[s];
        n--;
      }
    }
  }
  cout << s1 << " " << s2;
}
