#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 10;
long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= MOD) ret %= MOD;
    if (a >= MOD) a %= MOD;
    b >>= 1;
  }
  return ret;
}
long long invmod(long long x) { return power(x, MOD - 2); }
long long dp[55][2];
long long a[55];
long long n;
long long go(long long pos, long long check) {
  if (pos == n + 1) return 0;
  if (dp[pos][check] != -1) return dp[pos][check];
  long long ans = 0;
  if (check == 0) {
    ans += max(a[pos] + go(pos + 1, check ^ 1), go(pos + 1, check));
  } else {
    ans += min(go(pos + 1, check ^ 1), a[pos] + go(pos + 1, check));
  }
  dp[pos][check] = ans;
  return ans;
}
long long go1(long long pos, long long check) {
  if (pos == n + 1) return 0;
  if (dp[pos][check] != -1) return dp[pos][check];
  long long ans = 0;
  if (check == 0) {
    ans += min(go1(pos + 1, check ^ 1), a[pos] + go1(pos + 1, check));
  } else {
    ans += max(a[pos] + go1(pos + 1, check ^ 1), go1(pos + 1, check));
  }
  dp[pos][check] = ans;
  return ans;
}
int32_t main() {
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  memset(dp, -1, sizeof(dp));
  long long k = go1(1, 0);
  cout << k << " " << sum - k << endl;
}
