#include<bits/stdc++.h>
#define LL long long
#define x first
#define y second
#define de(x) cout<<#x<<" = "<<x<<" "
#define deg(x) cout<<#x<<" = "<<x<<endl
using namespace std;
const int N=110;
typedef pair<int,int> PII;
int f[N][N];
int a[N];
int s[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
for(int len=1;len<=n;len++)
for(int l=1;l+len-1<=n;l++)
{
int r=l+len-1;
f[l][r]=max(s[r]-s[l-1]-f[l+1][r],s[r]-s[l-1]-f[l][r-1]);
}
cout<<f[1][n]<<" "<<s[n]-f[1][n]<<endl;
return 0;
}