#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = a.back();
  vector<int> f(n);
  f[n - 1] = a.back();
  for (int i = n - 2; i >= 0; i--) {
    sum += a[i];
    f[i] = max(f[i + 1], sum - f[i + 1]);
  }
  cout << sum - f[0] << " " << f[0];
  return 0;
}
