#include <bits/stdc++.h>
using namespace std;
int dp[51];
int a[51];
int post[51];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  post[N - 1] = a[N - 1];
  for (int i = N - 2; i >= 0; i--) post[i] = a[i] + post[i + 1];
  dp[N - 1] = a[N - 1];
  for (int i = N - 2; i >= 0; i--) {
    dp[i] = max(dp[i + 1], a[i] + post[i + 1] - dp[i + 1]);
  }
  int ans1 = post[0] - dp[0];
  int ans2 = dp[0];
  printf("%d %d", ans1, ans2);
}
