#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > DIR_4 = {
    {-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int INF = 1000000000;
clock_t START_TIMER;
clock_t tic() { return START_TIMER = clock(); }
void toc(clock_t start = START_TIMER) {
  cout << "Elapsed time: " << (clock() - start) / (double)CLOCKS_PER_SEC << "s"
       << endl;
}
void printTable(int A[][2000], int m, int n) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) cout << A[i][j] << " ";
    cout << endl;
  }
}
void printTable(char A[][10], int m, int n) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) cout << A[i][j];
    cout << endl;
  }
}
void printCase(int c) { cout << "Case " << c << ":"; }
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long int> arr(n);
  for (auto &i : arr) cin >> i;
  int i = 0, j = n - 1;
  int s = 0, d = 0;
  bool f = true;
  while (i <= j) {
    if (f) {
      if (arr[i] > arr[j])
        s += arr[i++];
      else
        s += arr[j--];
    } else {
      if (arr[i] > arr[j])
        d += arr[i++];
      else
        d += arr[j--];
    }
    f = !f;
  }
  cout << s << " " << d << endl;
  return 0;
}
