#include <bits/stdc++.h>
using namespace std;
int dp[52][2];
int n;
int v[52];
int solve(int i, int turn) {
  if (i == n - 1) {
    if (turn == 0)
      return v[i];
    else
      return 0;
  }
  if (dp[i][turn] != -1) return dp[i][turn];
  int a, b;
  if (turn == 0) {
    a = solve(i + 1, 1) + v[i];
    b = solve(i + 1, 0);
    return dp[i][turn] = max(a, b);
  } else {
    a = solve(i + 1, 0);
    b = solve(i + 1, 1) + v[i];
    return dp[i][turn] = min(a, b);
  }
}
int main(void) {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += v[i];
  }
  int ans = solve(0, 0);
  printf("%d %d\n", sum - ans, ans);
  return 0;
}
