#include <bits/stdc++.h>
using namespace std;
template <class T>
T mceil(T a, T b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
const long long int M = 1e9 + 7;
const long long int N = 2e5 + 5;
const long long int inf = 9e18;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  pair<long long int, long long int> dp[n][2];
  dp[n - 1][0] = {v[n - 1], 0};
  dp[n - 1][1] = {0, v[n - 1]};
  for (long long int i = n - 2; i >= 0; i--) {
    if (dp[i + 1][1].first + v[i] > dp[i + 1][0].first) {
      dp[i][0].first = dp[i + 1][1].first + v[i];
      dp[i][0].second = dp[i + 1][1].second;
    } else {
      dp[i][0].first = dp[i + 1][0].first;
      dp[i][0].second = dp[i + 1][0].second + v[i];
    }
    if (dp[i + 1][0].second + v[i] > dp[i + 1][1].second) {
      dp[i][1].first = dp[i + 1][0].first;
      dp[i][1].second = dp[i + 1][0].second + v[i];
    } else {
      dp[i][1].second = dp[i + 1][1].second;
      dp[i][1].first = dp[i + 1][1].first + v[i];
    }
  }
  cout << dp[0][1].first << " " << dp[0][1].second << "\n";
}
