#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int a[52];
pair<int, int> dp[52][2];
int n;
pair<int, int> calc(int ind, int c) {
  pair<int, int> x, y;
  if (ind > n) return make_pair(0, 0);
  pair<int, int> &ans = dp[ind][c];
  if (ans != make_pair(-1, -1)) return ans;
  if (c == 0) {
    x = calc(ind + 1, 1);
    y = calc(ind + 1, 0);
    if (a[ind] + x.first > y.first)
      ans.first = a[ind] + x.first, ans.second = x.second;
    else
      ans.first = y.first, ans.second = a[ind] + y.second;
  } else {
    x = calc(ind + 1, 0);
    y = calc(ind + 1, 1);
    if (a[ind] + x.second > y.second)
      ans.second = a[ind] + x.second, ans.first = x.first;
    else
      ans.second = y.second, ans.first = a[ind] + y.first;
  }
  return ans;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i <= n; i++)
    dp[i][0] = make_pair(-1, -1), dp[i][1] = make_pair(-1, -1);
  pair<int, int> p = calc(0, 1);
  printf("%d %d\n", p.first, p.second);
  return 0;
}
