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