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