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