#include <bits/stdc++.h>
using namespace std;
int N;
int v[55];
int subsum[55];
int calculate(int pos) {
  if (pos >= N) return 0;
  int dp = calculate(pos + 1);
  int a = v[pos] + subsum[pos + 1] - dp;
  return max(a, dp);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> N;
  int suma = 0;
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
    suma += v[i];
  }
  for (int i = N - 1; i >= 0; --i) {
    subsum[i] = subsum[i + 1] + v[i];
  }
  int bob_eat = calculate(0);
  int alice_eat = suma - bob_eat;
  cout << alice_eat << " " << bob_eat << endl;
  return 0;
}
