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