#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int a[55];
int dp[55][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, j, k, m, n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = n; i >= 1; --i) {
    dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]);
    dp[i][1] = min(dp[i + 1][0], dp[i + 1][1]) + a[i];
  }
  cout << min(dp[1][0], dp[1][1]) << " " << max(dp[1][0], dp[1][1]) << endl;
  return 0;
}
