#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
int n, m;
int w[55];
int dp[55][2];
int solve(int i, int d) {
  int& ans = dp[i][d];
  if (i == n) return 0;
  if (ans == -1) {
    ans = 0;
    ans = max(w[i] - solve(i + 1, !d), -w[i] + solve(i + 1, d));
  }
  return ans;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  int sum = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%d", w + i);
    sum += w[i];
  }
  int ans = solve(0, 0);
  printf("%d %d\n", (sum - ans) / 2, (sum - ans) / 2 + ans);
  return 0;
}
