#include <bits/stdc++.h>
const int INF = 1e18L + 5;
using namespace std;
long long int M = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void input() {}
long long int n, a[55], sum = 0, dp[55][5];
long long int ans(long long int i, long long int j) {
  if (i == n) {
    return 0;
  }
  if (dp[i][j] != -1) {
    return dp[i][j];
  }
  if (j == 1) {
    return dp[i][j] = max(a[i] + ans(i + 1, 2), ans(i + 1, 1));
  } else {
    return dp[i][j] = min(ans(i + 1, 1), a[i] + ans(i + 1, 2));
  }
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long int val = ans(0, 1);
  cout << sum - val << " " << val;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  input();
  int t = 1, i = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
}
