#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int l = 0;
  int r = n - 1;
  int sum1 = 0;
  int sum2 = 0;
  int flag = 0;
  while (l <= r) {
    if (a[l] >= a[r]) {
      if (flag == 0) {
        sum1 += a[l];
        flag = 1;
        l++;
      } else {
        sum2 += a[l];
        flag = 0;
        l++;
      }
    } else {
      if (flag == 0) {
        sum1 += a[r];
        flag = 1;
        r--;
      } else {
        sum2 += a[r];
        flag = 0;
        r--;
      }
    }
  }
  cout << sum1 << " " << sum2 << endl;
  return 0;
}
