#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[201],f[201][201],g[201][201],maxn,minn=99999;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
a[n+i]=a[i];
}
for(int i=1;i<=2*n;i++)
a[i]+=a[i-1];
memset(f,127,sizeof(f));
memset(g,0,sizeof(g));
for(int i=1;i<=2*n;i++)
f[i][i]=g[i][i]=0;
for(int i=2*n;i>=2;i--)
for(int j=i+1;j<=2*n;j++)
for(int k=i;k<j;k++)
{
f[i][j]=min(f[i][j],f[i][k]+f[k+1][j]+a[j]-a[i-1]);
g[i][j]=max(g[i][j],g[i][k]+g[k+1][j]+a[j]-a[i-1]);
}
for(int i=1;i<=n;i++)
{
minn=min(minn,f[i][i+n-1]);
maxn=max(maxn,g[i][i+n-1]);
}
printf("%d\n%d",minn,maxn);
return 0;
}