#include <bits/stdc++.h>
using namespace std;
long long lcm_naive(int a, int b) {
  for (long l = 1; l <= (long long)a * b; ++l)
    if (l % a == 0 && l % b == 0) return l;
  return (long long)a * b;
}
int gcd_fast(int a, int b) {
  if (b == 0) return a;
  return gcd_fast(b, a % b);
}
long long lcm_fast(int a, int b) {
  int y = gcd_fast(a, b);
  long long x = (long long)a * b;
  if (y != 1)
    while ((x / y) % a == 0 && (x / y) % b == 0) x /= y;
  return x;
}
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  int d;
  int f = 0;
  int l = n - 1;
  bool x = false;
  int sd[2] = {0, 0};
  while (l >= f) {
    if (arr[l] > arr[f]) {
      sd[x] += arr[l];
      l--;
    } else {
      sd[x] += arr[f];
      f++;
    }
    x = !x;
  }
  cout << sd[0] << " " << sd[1];
  return 0;
}
