#include <bits/stdc++.h>
using namespace std;
long long n;
void input() { cin >> n; }
void solve() {
  vector<long long int> a(n);
  for (auto &it : a) cin >> it;
  long long x = 0, y = 0, l = 0, r = n - 1, t = 0;
  while (l <= r) {
    if (a[l] > a[r]) {
      if (!t)
        x += a[l];
      else
        y += a[l];
      l++;
    } else {
      if (!t)
        x += a[r];
      else
        y += a[r];
      r--;
    }
    t = 1 - t;
  }
  cout << x << " " << y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  long long t = 1;
  while (t--) {
    input();
    solve();
    cout << endl;
  }
  cin.get();
  return 0;
}
