#include <bits/stdc++.h>
using namespace std;
long long ara[55][5], b;
vector<long long> x;
long long dp(long long i, long long c) {
  if (i == x.size()) {
    return 0;
  }
  if (ara[i][c] != -1) return ara[i][c];
  long long ret, ret2, d;
  d = 1;
  ret = ret2 = 0;
  ret += (x[i] - dp(i + 1, c ^ d));
  ret2 -= (x[i] - dp(i + 1, c));
  return ara[i][c] = max(ret, ret2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n, ans, temp, t, j, i, a, mx, d, k, l, c;
  cin >> n;
  b = 0;
  memset(ara, -1, sizeof ara);
  for (i = 0; i < n; i++) {
    cin >> a;
    b += a;
    x.push_back(a);
  }
  ans = dp(0, 0);
  a = (ans + b) / 2;
  c = b - a;
  cout << c << " " << a;
  return 0;
}
