#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[n], d[n], sum;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  d[n - 1] = a[n - 1];
  sum = a[n - 1];
  for (long long int i = n - 2; i >= 0; i--) {
    sum += a[i];
    d[i] = max(d[i + 1], sum - d[i + 1]);
  }
  cout << sum - d[0] << " " << d[0] << "\n";
  return 0;
}
