#include <bits/stdc++.h>
using namespace std;
int arr[100], dp[100];
int n, sum = 0;
int calc(int x) {
  if (x == n + 1) return 0;
  int &ret = dp[x];
  if (ret != -(1 << 30)) return ret;
  ret = arr[x] - calc(x + 1);
  int theta = 0;
  for (int j = x; j < n; j++) {
    theta -= arr[j];
    ret = max(ret, theta + arr[j + 1] - calc(j + 2));
  }
  return ret;
}
int main() {
  cin >> n;
  for (int j = 1; j <= n; j++) {
    cin >> arr[j];
    sum += arr[j];
  }
  for (int j = 0; j < 100; j++) dp[j] = -(1 << 30);
  int shit = calc(1);
  cout << (sum - shit) / 2 << ' ' << (sum + shit) / 2 << endl;
}
