#include <bits/stdc++.h>
using namespace std;
int dp[51][2];
int n;
int arr[51];
int suffx[52];
int best(int idx, int tok) {
  if (idx == n) return 0;
  int& ret = dp[idx][tok];
  if (ret != -1) return ret;
  ret = 0;
  if (tok) {
    ret = max(ret, best(idx + 1, tok));
    ret = max(ret, best(idx + 1, 0) + arr[idx]);
  } else {
    ret = (suffx[n] - suffx[idx]) - best(idx, 1);
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    suffx[i + 1] = suffx[i] + arr[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << (suffx[n] - suffx[0]) - best(0, 1) << " " << best(0, 1) << endl;
}
