#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  vector<long long> suf(n + 1), dp(n + 1);
  suf[n] = dp[n] = 0;
  for (long long i = (n); --i >= 0;) {
    suf[i] = suf[i + 1] + a[i];
    dp[i] = max(dp[i + 1], a[i] + (suf[i + 1] - dp[i + 1]));
  }
  cout << suf[0] - dp[0] << ' ' << dp[0] << "\n";
}
