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