#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int l = 0, r = n - 1, S = 0, N = 0;
  while (l <= r) {
    if (v[l] > v[r]) {
      S += v[l];
      l++;
    } else {
      S += v[r];
      r--;
    }
    if (l > r) break;
    if (v[l] > v[r]) {
      N += v[l];
      l++;
    } else {
      N += v[r];
      r--;
    }
  }
  cout << S << " " << N;
}
