#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  pair<int, int> dp[n][2];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    dp[i][0].first = 0;
    dp[i][0].second = 0;
    dp[i][1].first = 0;
    dp[i][1].second = 0;
  }
  dp[n - 1][0] = {arr[n - 1], 0};
  dp[n - 1][1] = {0, arr[n - 1]};
  for (int i = n - 2; i >= 0; i--) {
    int a = arr[i] + dp[i + 1][1].first;
    int b = dp[i + 1][0].first;
    if (a > b) {
      dp[i][0] = {a, dp[i + 1][1].second};
    } else {
      dp[i][0] = {b, arr[i] + dp[i + 1][0].second};
    }
    a = arr[i] + dp[i + 1][0].second;
    b = dp[i + 1][1].second;
    if (a > b) {
      dp[i][1] = {dp[i + 1][0].first, a};
    } else {
      dp[i][1] = {arr[i] + dp[i + 1][1].first, b};
    }
  }
  cout << dp[0][1].first << " " << dp[0][1].second << endl;
  return 0;
}
