#include <bits/stdc++.h>
using namespace std;
long long INF = 123456789123456789L;
long long a[60];
long long dp[2][60];
int n;
long long mydp(int player, int pos) {
  if (dp[player][pos] != INF) {
    return dp[player][pos];
  }
  if (pos == n - 1) {
    if (player == 0)
      return dp[player][pos] = a[pos];
    else
      return dp[player][pos] = 0;
  }
  mydp(1 - player, pos + 1);
  mydp(player, pos + 1);
  if (player == 1) {
    return dp[player][pos] =
               min(dp[1 - player][pos + 1], a[pos] + dp[player][pos + 1]);
  } else {
    return dp[player][pos] =
               max(a[pos] + dp[1 - player][pos + 1], dp[player][pos + 1]);
  }
}
int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    dp[0][i] = dp[1][i] = INF;
    sum += a[i];
  }
  mydp(0, 0);
  printf("%I64d %I64d\n", sum - dp[0][0], dp[0][0]);
  return 0;
}
