#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], i;
  for (i = 0; i < n; i++) cin >> arr[i];
  int sum[n];
  sum[n - 1] = arr[n - 1];
  for (i = n - 2; i >= 0; i--) sum[i] = sum[i + 1] + arr[i];
  int bobb[n], boba[n];
  int aliceb[n], alicea[n];
  bobb[n - 1] = arr[n - 1];
  boba[n - 1] = 0;
  alicea[n - 1] = arr[n - 1];
  aliceb[n - 1] = 0;
  int j;
  for (j = n - 2; j >= 0; j--) {
    bobb[j] = max(arr[j] + boba[j + 1], bobb[j + 1]);
    alicea[j] = max(arr[j] + aliceb[j + 1], alicea[j + 1]);
    aliceb[j] = sum[j] - bobb[j];
    boba[j] = sum[j] - alicea[j];
  }
  cout << aliceb[0] << " " << bobb[0] << endl;
}
