#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long ar[n];
  for (long long pen = 0; pen < n; pen++) {
    cin >> ar[pen];
  };
  long long dp[n][2];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 2; j++) {
      dp[i][j] = 0;
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    if (i == (n - 1)) {
      dp[i][1] += ar[i];
    } else if (i == n - 1) {
      dp[i][1] = max(ar[i], ar[i + 1]);
      dp[i][0] = min(ar[i], ar[i + 1]);
    } else {
      dp[i][1] = max(dp[i + 1][1], ar[i] + dp[i + 1][0]);
      dp[i][0] = min(dp[i + 1][1], ar[i] + dp[i + 1][0]);
    }
  }
  cout << dp[0][0] << " " << dp[0][1] << "\n";
}
