#include <bits/stdc++.h>
using namespace std;
long long arr[100];
long long dp[100];
int main() {
  long long i, j, n, m, t;
  scanf("%lld", &n);
  long long sum = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    sum += arr[i];
  }
  long long diff = 1000000000000000;
  long long temp = 0;
  for (i = n - 1; i >= 0; i--) {
    dp[i] = max(dp[i + 1], arr[i] + temp - dp[i + 1]);
    temp += arr[i];
  }
  cout << temp - dp[0] << " " << dp[0] << endl;
}
