#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
const unsigned long long INF = 2009000999;
const float cp = 2 * acos(0.0);
const float eps = 1e-18;
const unsigned long long mod = 1000007;
using namespace std;
int main() {
  vector<unsigned long long> a;
  unsigned long long n, s1 = 0, s2 = 0, k = 0;
  cin >> n;
  a.resize(n);
  for (int(i) = 0; (i) < (n); i++) cin >> a[i];
  while (!a.empty()) {
    k++;
    if (a[0] > a[a.size() - 1]) {
      if (k % 2 != 0)
        s1 += a[0];
      else
        s2 += a[0];
      a.erase(a.begin());
    } else {
      if (k % 2 != 0)
        s1 += a[a.size() - 1];
      else
        s2 += a[a.size() - 1];
      a.erase(a.begin() + a.size() - 1);
    }
  }
  cout << s1 << ' ' << s2;
  return 0;
}
