#include <bits/stdc++.h>
using namespace std;
int mase(int i, vector<int> v, int sum, vector<int> &l) {
  if (i >= v.size()) return 0;
  if (l[i] != -1) return l[i];
  int d = sum - v[i];
  l[i] = max(sum - mase(i + 1, v, d, l), mase(i + 1, v, d, l));
  return l[i];
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    sum += v[i];
  }
  vector<int> l(n, -1);
  int ans = mase(0, v, sum, l);
  cout << sum - ans << " " << ans << endl;
}
