#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, t[N];
long long dp[N];
long long solve(int x, int k) {
  if (x >= n) return 0;
  if (dp[x] == -1) {
    long long mn = int(1e9);
    long long s = 0;
    for (int i = 1; x + i < n; i++) {
      s += t[x + i];
      mn = min(mn, s + solve(x + i + 2, 0));
    }
    dp[x] = max(t[x] + min(mn, (long long)solve(x + 2, 0)), solve(x + 1, 0));
  }
  return dp[x];
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    sum += t[i];
  }
  long long bob = solve(0, 0);
  cout << sum - bob << " " << bob;
}
