#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int c[x];
  int sp = 0, dp = 0;
  for (int i = 0; i < x; i++) cin >> c[i];
  int start = 0, end1 = x - 1;
  for (int i = 0; i < x; i++) {
    if (i % 2 == 0 || i == 0) {
      if (c[start] >= c[end1]) {
        sp += c[start];
      } else {
        sp += c[end1];
      }
    } else {
      if (c[start] >= c[end1]) {
        dp += c[start];
      } else {
        dp += c[end1];
      }
    }
    if (c[start] >= c[end1])
      start = start + 1;
    else
      end1 = end1 - 1;
  }
  cout << sp << " " << dp;
}
