#include <bits/stdc++.h>
using namespace std;
int t[55], s[55];
int dp[55];
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  int n;
  cin >> n;
  int suma = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    suma += t[i];
  }
  dp[n - 1] = t[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    int sum = 0;
    for (int j = i + 1; j < n; j++) sum += t[j];
    dp[i] = max(dp[i + 1], t[i] + sum - dp[i + 1]);
  }
  cout << suma - dp[0] << " " << dp[0] << '\n';
  return 0;
}
