#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ar;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  ar.resize(n);
  for (int i = 0; i < n; i++) cin >> ar[i];
  int l = 0, r = n - 1;
  int s1 = 0, s2 = 0;
  bool flag = true;
  while (l <= r) {
    if (flag) {
      if (ar[l] > ar[r]) {
        s1 += ar[l++];
      } else {
        s1 += ar[r--];
      }
    } else {
      if (ar[l] > ar[r]) {
        s2 += ar[l++];
      } else {
        s2 += ar[r--];
      }
    }
    flag = !flag;
  }
  cout << s1 << " " << s2;
}
