#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, n;
  cin >> n;
  long long int arr[n], a = 0, b = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = n - 1; i >= 0; i--) {
    if (a > b) {
      b = b + arr[i];
    } else {
      a = a + arr[i];
    }
  }
  cout << min(a, b) << " " << max(a, b);
  return 0;
}
