#include <bits/stdc++.h>
using namespace std;
int n, a[(int)(55)], sum, d[(int)(55)][2];
int dp(int x, int turn) {
  if (d[x][turn] != -1) return d[x][turn];
  if (x == n + 1) return 0;
  if (turn == 0)
    return d[x][turn] = max(dp(x + 1, !turn) + a[x], dp(x + 1, turn));
  else
    return d[x][turn] = min(dp(x + 1, !turn), dp(x + 1, turn) + a[x]);
}
int main() {
  memset(d, -1, sizeof(d));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  printf("%d %d", sum - dp(1, 0), dp(1, 0));
}
