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