#include <bits/stdc++.h>
using namespace std;
long long dp[105], v[105];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> v[i];
  dp[n] = 0;
  for (int i = n - 1; i >= 0; i--) dp[i] = abs(v[i] - dp[i + 1]);
  long long sum = accumulate(v, v + n, 0LL);
  cout << (sum - dp[0]) / 2 << ' ' << (sum + dp[0]) / 2 << '\n';
}
