#include <bits/stdc++.h>
using namespace std;
int p[1100];
int main() {
  int i, j, k;
  int n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &p[i]);
  int a = 0, b = 0;
  int l = 0, r = n - 1;
  int m = n;
  int t = 0;
  while (m--) {
    if (p[l] > p[r]) {
      if (t % 2 == 0)
        a += p[l];
      else
        b += p[l];
      l++;
    } else {
      if (t % 2 == 0)
        a += p[r];
      else
        b += p[r];
      r--;
    }
    t++;
  }
  printf("%d %d\n", a, b);
}
