#include <bits/stdc++.h>
using namespace std;
int N, X[100007];
long long S[100007], D[100007];
int main() {
  scanf("%d", &N);
  for (int i = (1); i <= (N); i++) scanf("%d", &X[i]);
  for (int i = (1); i <= (N); i++) S[i] = S[i - 1] + X[i];
  for (int i = (N); i >= (1); i--)
    D[i] = max(D[i + 1], S[N] - S[i] - D[i + 1] + X[i]);
  printf("%lld %lld\n", S[N] - D[1], D[1]);
}
