#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int power(long long int a, long long int b) {
  long long int value = 1;
  while (b) {
    if (b & 1) {
      value *= a;
    }
    a *= a;
    b /= 2;
  }
  return value;
}
long long int n;
long long int a[60];
long long int dp[60][2];
long long int solve(long long int id, int t) {
  if (id >= n) {
    return 0;
  }
  if (dp[id][t] != -1) {
    return dp[id][t];
  }
  long long int ans = 0;
  if (t == 0) {
    ans += max(a[id] + solve(id + 1, 1), solve(id + 1, 0));
  } else {
    ans += min(a[id] + solve(id + 1, 1), solve(id + 1, 0));
  }
  dp[id][t] = ans;
  return dp[id][t];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  long long int sum = 0;
  memset(dp, -1, sizeof(dp));
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long int x = solve(0, 0);
  cout << sum - x << " " << x << endl;
  return 0;
}
