#include <bits/stdc++.h>
using namespace std;
const int N = 51;
int v[N], dp[N][2], s[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    s[i] = s[i - 1] + v[i];
  }
  dp[n][1] = v[n];
  for (int i = n - 1; i >= 1; --i) {
    dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]);
    dp[i][1] = s[n] - s[i - 1] - dp[i][0];
  }
  cout << s[n] - max(dp[1][0], dp[1][1]) << ' ' << max(dp[1][0], dp[1][1]);
  return 0;
}
