#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); }
int LCM(int a, int b) {
  int temp = GCD(a, b);
  return temp ? (a / temp * b) : 0;
}
bool isPrime(int number) {
  if (number == 0 || number == 1) return false;
  int i;
  for (i = 2; i < number; i++) {
    if (number % i == 0) return false;
  }
  return true;
}
ll dive(ll num) {
  ll sum = 0;
  ll sq = (ll)sqrt(num);
  for (int i = 1; i <= sq; i++)
    if (num % i == 0) sum++;
  if (sq * sq == num)
    sum = (2 * sum) - 1;
  else {
    sum = sum * 2;
  }
  return sum;
}
template <class t>
void printVec(vector<t> v2, string s = "") {
  cout << s;
  for (int i = 0; i < (int)v2.size(); ++i) cout << v2[i] << " ";
  cout << "\n";
}
void printVec_2D_int(vector<vector<int>> v2, int r, int c, string s = "") {
  int counter = 1;
  cout << s;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      if (j == c - 1) {
        cout << v2[i][j] << endl;
      } else
        cout << v2[i][j] << " ";
    }
  cout << "\n";
}
bool odd(int num) { return num % 2 != 0; }
ll combi(int n, int k) {
  long long ans = 1;
  k = k > n - k ? n - k : k;
  int j = 1;
  for (; j <= k; j++, n--) {
    if (n % j == 0) {
      ans *= n / j;
    } else if (ans % j == 0) {
      ans = ans / j * n;
    } else {
      ans = (ans * n) / j;
    }
  }
  return ans;
}
ll power(int base, int p) {
  if (p == 0) return 1;
  ll result = base;
  for (int i = 0; i < p - 1; i++) {
    result *= base;
    if (result > 1000000007) result = result % 1000000007;
  }
  return result;
}
void print_Arr_Int(int *arr, int l) {
  for (int i = 0; i < l; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
void recBitOfNum(int n) {}
int NumFromBinary(string s) {
  int li, l;
  ll n = 0;
  l = s.length();
  li = l - 1;
  for (int i = 0; i < l; i++) {
    if (s[i] % '1') {
      n += power(2, li);
    }
    li--;
  }
  return n;
}
int reverse(int x) {
  int y = 0;
  y = x % 10;
  x /= 10;
  while (x > 0) {
    y *= 10;
    y += x % 10;
    x /= 10;
  }
  return y;
}
int main() {
  int x, n, Sereja = 0, Dima = 0;
  cin >> x;
  vector<int> v;
  for (int i = 0; i < x; i++) {
    cin >> n;
    v.push_back(n);
  }
  while (!v.empty()) {
    if (v[0] > v[v.size() - 1]) {
      Sereja += v[0];
      int len = v.size();
      for (int i = 0; i < len - 1; i++) {
        v[i] = v[i + 1];
      }
    } else {
      Sereja += v[v.size() - 1];
    }
    v.pop_back();
    if (v.empty()) break;
    if (v[0] > v[v.size() - 1]) {
      Dima += v[0];
      int len = v.size();
      for (int i = 0; i < len - 1; i++) {
        v[i] = v[i + 1];
      }
    } else {
      Dima += v[v.size() - 1];
    }
    v.pop_back();
  }
  cout << Sereja << " " << Dima << endl;
  return 0;
}
