#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const int mod = 1000000007;
using namespace std;
int v[55], diff[55], n;
int main() {
  cin >> n;
  int sum = 0;
  for (int i = (int)(0); i < (int)(n); ++i) {
    scanf("%d", &v[i]);
    sum += v[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    diff[i] = abs(v[i] - diff[i + 1]);
  }
  cout << (sum - diff[0]) / 2 << " " << (sum + diff[0]) / 2 << endl;
  return 0;
}
