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