#include <bits/stdc++.h>
const int MAXN(1e5 + 5);
inline int read() {
  char ch(getchar());
  int x(0);
  int flag(1);
  while (!isdigit(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return flag * x;
}
int sum[MAXN];
int a[MAXN];
int dp[MAXN];
int main() {
  int n(read());
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  for (int i = n; i >= 1; i--) {
    sum[i] = sum[i + 1] + a[i];
    dp[i] = std::max(dp[i + 1], sum[i + 1] - dp[i + 1] + a[i]);
  }
  std::printf("%d %d\n", sum[1] - dp[1], dp[1]);
  return 0;
}
