#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int s1, s2;
  s1 = s2 = 0;
  int l = 0, h = n - 1;
  int f = 1;
  while (l <= h) {
    if (f) {
      s1 += max(a[l], a[h]);
      if (a[h] > a[l])
        h--;
      else
        l++;
      f = 0;
    } else {
      s2 += max(a[l], a[h]);
      if (a[h] > a[l])
        h--;
      else
        l++;
      f = 1;
    }
  }
  cout << s1 << " " << s2 << endl;
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  solve();
  return 0;
}
