#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
long long zc,maxdis,temp,temp2,s[100010];
int main(void)
{
freopen("circlea.in","r",stdin);
freopen("circlea.out","w",stdout);
int i,j,n;
cin>>n;
for (i=1;i<=n;i++)
{
cin>>s[i];
s[i]+=s[i-1];
}
zc=s[n];
for (i=1;i<=n;i++)
for (j=i+1;j<=n;j++)
{
temp=s[j]-s[i];
temp2=zc-temp;
if (temp>temp2)
temp=temp2;
if (maxdis<temp)
maxdis=temp;
}
cout<<maxdis<<endl;
return(0);
}