#include <bits/stdc++.h>
using namespace std;
int n;
int pies[51];
int memo[51][2];
int dp(int pos, int x) {
  if (pos == n) return 0;
  if (memo[pos][x] != -1) {
    return memo[pos][x];
  }
  int ans1 = 2147483646;
  int ans2 = 2147483646;
  if (x == 0) {
    ans1 = pies[pos] + dp(pos + 1, x ^ 1);
    ans2 = dp(pos + 1, x);
    return memo[pos][x] = max(ans1, ans2);
  } else {
    ans1 = dp(pos + 1, x ^ 1);
    ans2 = pies[pos] + dp(pos + 1, x);
    return memo[pos][x] = min(ans1, ans2);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> pies[i];
    sum += pies[i];
  }
  memset(memo, -1, sizeof memo);
  int ans = dp(0, 0);
  int alice = sum - ans;
  cout << alice << " " << ans << endl;
}
