#include <bits/stdc++.h>
using namespace std;
int n;
int a[100];
int total[100];
long long dp[51];
int main() {
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt += a[i];
  }
  dp[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    dp[i] = max(a[i] - dp[i + 1], dp[i + 1] - a[i]);
  }
  cout << (cnt - dp[0]) / 2 << " " << (cnt + dp[0]) / 2 << endl;
  return 0;
}
