#include <bits/stdc++.h>
using namespace std;
using std::cin;
using std::cout;
long long MOD = 998244353;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int dp[n + 1];
  int pre[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    dp[i] = 0;
    pre[i] = 0;
  }
  dp[n] = 0;
  pre[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    int maxnum = -1;
    for (int c = i; c < n; c++) {
      maxnum = max(maxnum, arr[c] + pre[c + 1] - dp[c + 1]);
    }
    dp[i] = maxnum;
    pre[i] = pre[i + 1] + arr[i];
  }
  cout << pre[0] - dp[0] << " " << dp[0];
  return 0;
}
