#include <bits/stdc++.h>
using namespace std;
int n, p[50], ss[50], dp[50];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  ss[n - 1] = p[n - 1];
  dp[n - 1] = p[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    ss[i] = p[i] + ss[i + 1];
    dp[i] = max(dp[i + 1], p[i] + ss[i + 1] - dp[i + 1]);
  }
  cout << ss[0] - dp[0] << " " << dp[0] << endl;
  return 0;
}
