#include <bits/stdc++.h>
using namespace std;
const int N = 5e6 + 10;
const int M = 51;
int arr[M];
int memo[M][2];
int n, sum;
int dp(int idx, int p) {
  if (idx == n + 1) return 0;
  int &ret = memo[idx][p];
  if (ret != -1) return ret;
  ret = 0;
  if (p == 0) {
    int x, y, x2, y2;
    x2 = arr[idx] + dp(idx + 1, p);
    y2 = dp(idx + 1, 1 - p);
    x = sum - x2;
    y = sum - y2;
    if (x >= y)
      ret = max(ret, x2);
    else
      ret = max(ret, y2);
  } else {
    ret = max(ret, arr[idx] + dp(idx + 1, 1 - p));
    ret = max(ret, dp(idx + 1, p));
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  memset(memo, -1, sizeof(memo));
  int x = dp(1, 0);
  cout << x << " " << sum - x;
  return 0;
}
