#include <bits/stdc++.h>
using namespace std;
const int MOD = int(1e9) + 7;
const long long inf = 1e18 + 5;
const int offset = 3000;
int main() {
  int n;
  scanf("%d", &n);
  int arr[55], dp[55][2];
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  dp[n][1] = arr[n];
  dp[n][0] = 0;
  for (int i = n - 1; i > 0; i--) {
    dp[i][1] = max(dp[i + 1][1], arr[i] + dp[i + 1][0]);
    dp[i][0] = min(dp[i + 1][1], arr[i] + dp[i + 1][0]);
  }
  cout << dp[1][0] << " " << dp[1][1];
  return 0;
}
