#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 10;

int a[N], n, sum[2];

bool check(int x) {
  int sum = 0;
  for(int i = 1; i <= n; i += 2) {
    if(sum >= x) { 
      sum = max(sum + a[i] - a[i - 1], a[i]);
    } else {
      sum += a[i] - a[i - 1];
    }
  }
  return sum >= x;
}

int main(void) {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i & 1] += a[i];
  }
  if(~n & 1) {
    cout << max(sum[0], sum[1]) << " " << min(sum[0], sum[1]) << endl;
  } else {
    int ans = 0, l = 0, r = sum[1];
    while(l <= r) {
      int mid = l + r >> 1;
      if(check(mid)) {
	ans = mid;
	l = mid + 1;
      } else {
	r = mid - 1;
      }
    }
    cout << sum[0] + ans << " " << sum[1] - ans << endl;
  }
  return 0;
}
