#include <bits/stdc++.h>
using namespace std;
long long n, a[51], A, B;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 1; i--) {
    A = A + a[i];
    if (A > B) swap(A, B);
  }
  cout << A << " " << B << endl;
  return 0;
}
