#include <bits/stdc++.h>
using namespace std;
int N;
int csum[50];
int pie[50];
int rec(int i) {
  if (i == N - 1) return pie[i];
  int tmp = rec(i + 1);
  pie[i] = max(csum[i + 1] - tmp + pie[i], tmp);
  return pie[i];
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> pie[i];
  for (int i = N - 1; i >= 0; i--) {
    csum[i] = 0;
    if (i + 1 < N) csum[i] = csum[i + 1];
    csum[i] += pie[i];
  }
  int bob = rec(0);
  int alice = csum[0] - bob;
  cout << alice << " " << bob << endl;
}
