#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[50], sum = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  int dp[51], k = n;
  dp[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (dp[i + 1] > a[i] + dp[k]) {
      dp[i] = dp[i + 1];
      dp[k] += a[i];
    } else {
      dp[i] = a[i] + dp[k];
      k = i + 1;
    }
  }
  cout << sum - dp[0] << ' ' << dp[0];
}
