#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int i = 0, j = n - 1, k = 1, s1 = 0, s2 = 0;
  while (i <= j) {
    if (a[i] > a[j]) {
      if ((k & 1) == 1)
        s1 += a[i];
      else
        s2 += a[i];
      i++;
    } else {
      if ((k & 1) == 1)
        s1 += a[j];
      else
        s2 += a[j];
      j--;
    }
    k++;
  }
  cout << s1 << " " << s2;
  return 0;
}
