#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n;
int a[N];
int dp[N];
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp[i] = max(a[i] - dp[i + 1], dp[i + 1] - a[i]);
  }
  int sum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  cout << (sum - dp[0]) / 2 << " " << (sum + dp[0]) / 2 << endl;
  return 0;
}
