#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = 0;
  x = n;
  vector<int> A;
  vector<int> dp(n);
  vector<int> dp2(n);
  int sum = 0;
  while (x--) {
    int x;
    cin >> x;
    A.push_back(x);
    sum += x;
  }
  dp[n - 1] = A[n - 1];
  dp2[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    int maxi = max(A[i] + dp2[i + 1], dp[i + 1]);
    int mini = min(A[i] + dp2[i + 1], dp[i + 1]);
    dp[i] = maxi;
    dp2[i] = mini;
  }
  cout << sum - dp[0] << " " << dp[0];
  return 0;
}
