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