#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
int a[100000 + 4];
int main() {
  fast();
  int n, sum_s = 0, sum_d = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int st = 0, en = n - 1;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      if (a[st] > a[en]) {
        sum_s += a[st];
        st++;
      } else {
        sum_s += a[en];
        en--;
      }
    } else {
      if (a[st] > a[en]) {
        sum_d += a[st];
        st++;
      } else {
        sum_d += a[en];
        en--;
      }
    }
  }
  cout << sum_s << " " << sum_d;
}
