#include <bits/stdc++.h>
using namespace std;
void CI(int &_x) { scanf("%d", &_x); }
void CI(int &_x, int &_y) {
  CI(_x);
  CI(_y);
}
void CI(int &_x, int &_y, int &_z) {
  CI(_x);
  CI(_y, _z);
}
void CI(int &_a, int &_b, int &_c, int &_d) {
  CI(_a, _b);
  CI(_c, _d);
}
template <typename T>
void getarray(T a[], int b, int e) {
  for (int i = b; i < e + b; i++) cin >> a[i];
}
template <typename T>
void printarray(T a[], int b, int e) {
  for (int i = b; i < e - 1 + b; i++) cout << a[i] << " ";
  cout << a[e - 1 + b] << endl;
}
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
int dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};
int dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dr4[4] = {0, 0, 1, -1};
int dc4[4] = {-1, 1, 0, 0};
int kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};
int main() {
  deque<int> dq;
  int n, i, j, ser = 0, dim = 0;
  CI(n);
  for (i = 0; i < n; i++) {
    CI(j);
    dq.push_back(j);
  }
  bool fucka = 0;
  while (!dq.empty()) {
    int r, l, val;
    r = dq.back();
    l = dq.front();
    if (r > l) {
      val = r;
      dq.pop_back();
    } else {
      val = l;
      dq.pop_front();
    }
    if (fucka == 0) {
      ser += val;
      fucka = 1;
    } else {
      dim += val;
      fucka = 0;
    }
  }
  cout << ser << " " << dim << endl;
}
