#include <bits/stdc++.h>
using namespace std;
bool qf = false;
int n, i, a[1000], l, r, sereja, dima, mov = 1;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  l = 0;
  r = n - 1;
  while (l <= r) {
    if (mov == 1)
      sereja += a[l] > a[r] ? a[l++] : a[r--], mov = 2;
    else
      dima += a[l] > a[r] ? a[l++] : a[r--], mov = 1;
  }
  printf("%d %d", sereja, dima);
  return 0;
}
