#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, a[N];
int dp[N][2][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  dp[n][1][1] = a[n];
  dp[n][0][0] = a[n];
  for (int i = n - 1; i >= 1; --i) {
    if ((dp[i + 1][0][0]) > dp[i][0][0]) {
      dp[i][0][0] = dp[i + 1][0][0];
      dp[i][0][1] = dp[i + 1][0][1] + a[i];
    }
    if ((dp[i + 1][1][0] + a[i]) > dp[i][0][0]) {
      dp[i][0][0] = dp[i + 1][1][0] + a[i];
      dp[i][0][1] = dp[i + 1][1][1];
    }
    if ((dp[i + 1][0][1] + a[i]) > dp[i][1][1]) {
      dp[i][1][1] = dp[i + 1][0][1] + a[i];
      dp[i][1][0] = dp[i + 1][0][0];
    }
    if ((dp[i + 1][1][1]) > dp[i][1][1]) {
      dp[i][1][1] = dp[i + 1][1][1];
      dp[i][1][0] = dp[i + 1][1][0] + a[i];
    }
  }
  printf("%d %d\n", dp[1][1][0], dp[1][1][1]);
  return 0;
}
