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