#include <bits/stdc++.h>
using namespace std;
int n;
int a[55];
int sum[55];
int dp[55];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + a[i];
  for (int i = n - 1; i >= 0; i--) {
    dp[i] = max(dp[i + 1], sum[i] - dp[i + 1]);
  }
  cout << sum[0] - dp[0] << ' ' << dp[0] << '\n';
}
