#include <bits/stdc++.h>
using namespace std;
int a[55], sum[55], dp[55];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(a, 0, sizeof(a));
    memset(sum, 0, sizeof(sum));
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + a[i];
    for (int i = n - 1; i >= 0; i--)
      dp[i] = max(dp[i + 1], sum[i + 1] - dp[i + 1] + a[i]);
    printf("%d %d\n", sum[0] - dp[0], dp[0]);
  }
}
