#include <bits/stdc++.h>
using namespace std;
void solution() {
  long long n;
  cin >> n;
  int a[n];
  for (auto i = 0; i < n; i++) cin >> a[i];
  long long s = 0, d = 0;
  int f = 0, l = n - 1;
  int turn = 1;
  while (n > 0) {
    if (max(a[f], a[l]) == a[f]) {
      if (turn & 1)
        s += a[f];
      else
        d += a[f];
      f++;
    } else {
      if (turn & 1)
        s += a[l];
      else
        d += a[l];
      l--;
    }
    n--;
    turn++;
  }
  cout << s << " " << d;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solution();
  return 0;
}
