#include<iostream>
#include<cstdio>
using namespace std;
#define N 300012
int n,co[2],a[N],s[N],ans=0;
inline bool can(int mid){int i,v=0;for(i=2;i<=n;i+=2)if(s[i-1]>=(mid+v))v=min(v,s[i]);return (s[n]>=(mid+v));}
int main(){
	scanf("%d",&n);int i,l,r,mid;for(i=1;i<=n;i++){scanf("%d",&a[i]);co[i&1]+=a[i];}
	if(!(n&1)){printf("%d %d",max(co[0],co[1]),min(co[0],co[1]));return 0;}
	for(i=1;i<=n;i++)s[i]=s[i-1]+((i&1)?a[i]:(-a[i]));l=1;r=1e9;
	while(l<=r){mid=(l+r)>>1;if(can(mid)){ans=mid;l=mid+1;}else r=mid-1;}printf("%d %d",co[0]+ans,co[1]-ans);return 0;
}