#include <bits/stdc++.h>
using namespace std;
int n, c[10005], a, i, b;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = n; i >= 1; i--)
    if (a >= b)
      b = b + c[i];
    else
      a = a + c[i];
  cout << min(a, b) << " " << max(a, b);
}
