#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n, long long lelo) {
  if (n == 0) return 1;
  if (n == 1) return a;
  if (n == 2) return (a * a) % lelo;
  if (n % 2)
    return (a * power(a, n - 1, lelo)) % lelo;
  else
    return power(power(a, n / 2, lelo), 2, lelo) % lelo;
}
void swap(long long &a, long long &b) {
  auto tm = a;
  a = b;
  b = tm;
}
const long long N = 1e5 + 5;
const long long INF = 1e18;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long(i) = (0); (i) < (n); (i)++) cin >> v[i];
  vector<long long> dp(n), a(n);
  a[n - 1] = v[n - 1];
  for (long long i = n - 2; i >= 0; i--) a[i] = v[i] + a[i + 1];
  dp[n - 1] = v[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    dp[i] = max(v[i] + a[i + 1] - dp[i + 1], dp[i + 1]);
  }
  cout << a[0] - dp[0] << " " << dp[0];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long double tt = 1.0 * clock();
  long long t = 1;
  for (long long(i) = (1); (i) < (t + 1); (i)++) {
    solve();
    if (i < t) cout << "\n";
  }
  tt = 1.000000000 * (clock() - tt) / CLOCKS_PER_SEC;
  return 0;
}
