#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
const int N=3e5+1;
int n, a[N], s[N];
int main() {
	int sum[2]={};
	assert(scanf("%d", &n)==1);
	for(int i=1; i<=n; ++i) {
		assert(scanf("%d", a+i)==1);
		sum[i%2]+=a[i];
		s[i]=s[i-1]+(i%2==1?a[i]:-a[i]);
	}
	if(n%2==0) {
		std::sort(sum, sum+2);
		printf("%d %d\n", sum[1], sum[0]);
		return 0;
	}
	int l=0, r=sum[1];
	while(l<r) {
		int x=(l+r+1)/2, min=0;
		for(int i=2; i<n; i+=2) if(s[i-1]-min>=x&&s[i]<min) min=s[i];
		if(s[n]-min>=x) l=x; else r=x-1;
	}
	printf("%d %d\n", sum[0]+l, sum[1]-l);
	return 0;
}
