#include <bits/stdc++.h>
using namespace std;
int v[55], sum = 0, d[55], n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  d[n] = v[n];
  for (int i = n - 1; i >= 1; i--) {
    d[i] = max(v[i] - d[i + 1], d[i + 1] - v[i]);
  }
  int a, b;
  b = (sum + d[1]) / 2;
  a = sum - b;
  cout << a << " " << b;
  return 0;
}
