#include <bits/stdc++.h>
using namespace std;
void setup();
using namespace std;
int main() {
  setup();
  int n, seraja = 0, dima = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int l = 0, r = n - 1;
  for (int i = 0; i < n; i++) {
    if (a[l] > a[r]) {
      i % 2 == 0 ? seraja += a[l] : dima += a[l];
      l++;
    } else {
      i % 2 == 0 ? seraja += a[r] : dima += a[r];
      r--;
    }
  }
  cout << seraja << " " << dima;
  return 0;
}
void setup() { ios_base::sync_with_stdio(false); }
