#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1E9 + 7;
const long long N = 505;
long long n;
long long a[N];
pair<long long, long long> dp[N][3];
pair<long long, long long> recur(long long ind, long long dec) {
  if (ind == n + 1) {
    dp[n + 1][dec] = make_pair(0, 0);
    return make_pair(0, 0);
  } else if (dp[ind][dec] != make_pair(-1LL, -1LL))
    return dp[ind][dec];
  if (dec == 1) {
    pair<long long, long long> x = recur(ind + 1, 2);
    pair<long long, long long> y = recur(ind + 1, 1);
    if (x.first + a[ind] > y.first) {
      dp[ind][dec] = make_pair(x.first + a[ind], x.second);
      return make_pair(x.first + a[ind], x.second);
    } else {
      dp[ind][dec] = make_pair(y.first, y.second + a[ind]);
      return make_pair(y.first, y.second + a[ind]);
    }
  } else {
    pair<long long, long long> x = recur(ind + 1, 1);
    pair<long long, long long> y = recur(ind + 1, 2);
    if (x.second + a[ind] > y.second) {
      dp[ind][dec] = make_pair(x.first, x.second + a[ind]);
      return make_pair(x.first, x.second + a[ind]);
    } else {
      dp[ind][dec] = make_pair(y.first + a[ind], y.second);
      return make_pair(y.first + a[ind], y.second);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("inp.txt", "r")) {
    freopen("inp.txt", "r", stdin);
    freopen("outp.txt", "w", stdout);
  }
  cin >> n;
  long long i;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n + 1; i++) dp[i][1] = dp[i][2] = make_pair(-1, -1);
  pair<long long, long long> ans = recur(1, 1);
  cout << ans.second << " " << ans.first;
  return 0;
}
