#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[10000], al = 0, bob = 0, f = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  bob = a[n - 1], al = 0;
  for (int i = n - 2; i >= 0; i--) {
    al += a[i];
    if (bob < al) {
      swap(bob, al);
    }
  }
  cout << al << " " << bob;
  return 0;
}
