#include <bits/stdc++.h>
using namespace std;
int size[110], dp[110][2], sum = 0;
signed main() {
  int i, j, k, n, m;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &size[i]);
    sum += size[i];
  }
  dp[n - 1][0] = size[n - 1];
  dp[n - 1][1] = 0;
  for (i = n - 2; i >= 0; i--) {
    dp[i][0] = max(dp[i + 1][0], dp[i + 1][1] + size[i]);
    dp[i][1] = min(dp[i + 1][0], dp[i + 1][1] + size[i]);
  }
  printf("%d %d\n", sum - dp[0][0], dp[0][0]);
}
