#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n;
  scanf("%d", &n);
  int* pte = new int[n];
  for (int i = 0; i < n; ++i) cin >> pte[i];
  int b = 0, e = n - 1;
  int st1 = 0, st2 = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      if (pte[b] > pte[e]) {
        st1 += pte[b];
        ++b;
      } else {
        st1 += pte[e];
        --e;
      }
    } else if (i % 2 != 0) {
      if (pte[b] > pte[e]) {
        st2 += pte[b];
        ++b;
      } else {
        st2 += pte[e];
        --e;
      }
    }
  }
  printf("%d %d", st1, st2);
  return 0;
}
