#include <bits/stdc++.h>
using namespace std;
long long n, arr[55] = {}, sm = 0, dp[55][2] = {};
long long rec(int ind, bool dt) {
  if (ind == n - 1) {
    if (dt)
      return 0;
    else
      return arr[ind];
  }
  if (dp[ind][dt] != -1) return dp[ind][dt];
  if (dt)
    return dp[ind][dt] = min(rec(ind + 1, dt) + arr[ind], rec(ind + 1, !dt));
  else
    return dp[ind][dt] = max(rec(ind + 1, dt), rec(ind + 1, !dt) + arr[ind]);
}
int main() {
  cin >> n;
  for (int i = 0; i < 55; i++) {
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sm += arr[i];
  }
  long long ans = rec(0, 0);
  cout << (sm - ans) << " " << ans << "\n";
  return 0;
}
