#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, z, x = 0, y = 0, p, q, l, T, m, ans = 0, t;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  i = 0;
  j = n - 1;
  for (k = 0; k < n; k++) {
    if (a[i] >= a[j]) {
      z = a[i];
      i++;
    } else {
      z = a[j];
      j--;
    }
    if (k % 2 == 0)
      x = x + z;
    else
      y = y + z;
  }
  cout << x << " " << y;
  return 0;
}
