#include <bits/stdc++.h>
using namespace std;
int dp[55][2];
int k[55], su[55];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    su[i] = su[max(i - 1, 0)] + k[i];
  }
  for (int i = n - 1; i > -1; i--) {
    dp[i][1] = max(dp[i + 1][0] + k[i], dp[i + 1][1]);
    dp[i][0] = min(dp[i + 1][0] + k[i], dp[i + 1][1]);
  }
  cout << su[n - 1] - dp[0][1] << " " << dp[0][1];
}
