#include <bits/stdc++.h>
using namespace std;
long long sum, n, arr[64], dp[64][4];
long long rec(int pos, bool who) {
  if (dp[pos][who] != 0) return dp[pos][who];
  if (pos == n) {
    if (who == 0)
      return arr[pos];
    else
      return 0;
  }
  if (who == 0) {
    return dp[pos][who] = max(rec(pos + 1, 1) + arr[pos], rec(pos + 1, 0));
  } else
    return dp[pos][who] = min(rec(pos + 1, 1) + arr[pos], rec(pos + 1, 0));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  long long k = rec(1, 0);
  cout << sum - k << " " << k << endl;
  return 0;
}
