#include <bits/stdc++.h>
using namespace std;
template <typename T, typename... V>
inline void wonl(T t, V... v) {
  ww(t);
  if (sizeof...(v)) putchar(' ');
  wonl(v...);
}
template <typename T, typename... V>
inline void wws(T t, V... v) {
  ww(t);
  putchar(' ');
  wws(v...);
}
template <typename T, typename... V>
inline void dbg(T t, V... v) {
  cout << ' ' << t;
  dbg(v...);
}
int main() {
  int n;
  cin >> n;
  int a[1001];
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
  }
  int serja = 0, dima = 0;
  bool turn = true;
  int low = 0, high = n - 1;
  while (low <= high) {
    int cur;
    if (a[low] > a[high]) {
      cur = a[low];
      ++low;
    } else {
      cur = a[high];
      --high;
    }
    if (turn)
      serja += cur;
    else {
      dima += cur;
    }
    turn = !turn;
  }
  cout << serja << " " << dima << "\n";
}
