#include <bits/stdc++.h>
using namespace std;
int n, lis[55], dp[2][55];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> lis[i];
  dp[0][n] = lis[n];
  for (int i = (n - 1); i >= (1); i--) {
    int way1 = lis[i] + dp[1][i + 1];
    int way2 = dp[0][i + 1];
    if (way1 > way2)
      dp[0][i] = way1, dp[1][i] = way2;
    else
      dp[0][i] = way2, dp[1][i] = way1;
  }
  cout << dp[1][1] << ' ' << dp[0][1];
}
