#include <bits/stdc++.h>
using namespace std;
const int N = 60;
long long arr[N], dp[N][2];
long long power_mod(long long x, long long y) {
  x %= 1000000007;
  long long res = 1;
  while (y) {
    if (y & 1) {
      res = (res * x) % 1000000007;
    }
    y /= 2;
    x = (x * x) % 1000000007;
  }
  return res;
}
void solve() {
  long long total = 0;
  int n, flag = 1;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    total += arr[i];
  }
  dp[n + 1][1] = dp[n + 1][2] = 0;
  for (int i = n; i >= 1; i--) {
    dp[i][1] = max(arr[i] + dp[i + 1][2], dp[i + 1][1]);
    dp[i][2] = min(arr[i] + dp[i + 1][2], dp[i + 1][1]);
  }
  cout << total - dp[1][1] << " " << dp[1][1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
