#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int sum = accumulate(a.begin(), a.end(), 0);
  vector<vector<int>> dp(n + 1, vector<int>(2, -1));
  function<int(int, int)> solve = [&](int idx, int cur) {
    if (idx == n) return 0;
    if (dp[idx][cur] != -1) return dp[idx][cur];
    int res = 0;
    if (cur == 0)
      res = max(a[idx] + solve(idx + 1, !cur), solve(idx + 1, cur));
    else
      res = min(solve(idx + 1, !cur), a[idx] + solve(idx + 1, cur));
    return dp[idx][cur] = res;
  };
  int ans = solve(0, 0);
  cout << sum - ans << ' ' << ans << '\n';
  return 0;
}
