#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[100];
  int n;
  cin >> n;
  int sum = 0, tot = 0;
  ;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    tot += arr[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    sum = abs(arr[i] - sum);
  }
  cout << (tot - sum) / 2 << " " << (tot + sum) / 2 << "\n";
}
