#include <bits/stdc++.h>
using namespace std;
int n;
int a[100009];
long long sum = 0;
int dp[109][3];
int ssss(int i, int is) {
  if (i == n) return 0;
  if (dp[i][is] != -1) return dp[i][is];
  int d;
  if (is == 0) {
    d = min(a[i] + ssss(i + 1, 0), ssss(i + 1, 1));
    return d;
  } else {
    d = max(a[i] + ssss(i + 1, !is), ssss(i + 1, is));
    return dp[i][is] = d;
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long ans = ssss(0, 0);
  cout << ans << " " << sum - ans;
}
