#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int i;
  long long s = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    s += arr[i];
  }
  long long c = 0, d = 0;
  c = arr[n - 1];
  for (i = n - 2; i >= 0; i--) {
    c = abs(arr[i] - c);
  }
  long long a = (s - c) / 2;
  long long b = a + c;
  cout << a << " " << b;
}
