#include<bits/stdc++.h>
#define ll int
using namespace std;
ll n,ar[1000];
struct trie
{
trie *bit[2];
ll R;
trie()
{
bit[0]=bit[1]=NULL;
R=1e18;
}
};
trie *root=new trie();
inline void insert(ll val,ll r)
{
ll now;
trie *curr=root;
for(ll i=20;i>=0;i--)
{
now=min(1,val&(1<<i));
if(curr->bit[now]==NULL)
{
trie *temp=new trie();
curr->bit[now]=temp;
curr=temp;
}
else
curr=curr->bit[now];
curr->R=min(curr->R,r);
}
}
inline ll query(ll val,ll l)
{
ll now,lookfor,ans=0;
trie *curr=root;
for(ll i=20;i>=0;i--)
{
now=min(1,val&(1<<i));
lookfor=1^now;
//try for lookfor
if(curr->bit[lookfor]!=NULL)
{
if(curr->bit[lookfor]->R<l)
{
ans+=(1<<i);
curr=curr->bit[lookfor];
continue;
}
}
//i could not get lookfor
//so try for now
if(curr->bit[now]!=NULL)
{
if(curr->bit[now]->R<l)
{
curr=curr->bit[now];
continue;
}
}
return 0;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(ll i=0;i<n;i++)
cin>>ar[i];
ll sum,ans=-1e18;
for(ll i=0;i<n;i++)
{
sum=0;
for(ll j=i;j<n;j++)
{
sum+=ar[j];
ans=max(ans,query(sum,i));
insert(sum,j);
}
}
cout<<ans;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBpbnQKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixhclsxMDAwXTsKc3RydWN0IHRyaWUKewogICAgdHJpZSAqYml0WzJdOwogICAgbGwgUjsKICAgIHRyaWUoKQogICAgewogICAgICAgIGJpdFswXT1iaXRbMV09TlVMTDsKICAgICAgICBSPTFlMTg7CiAgICB9Cn07CnRyaWUgKnJvb3Q9bmV3IHRyaWUoKTsKaW5saW5lIHZvaWQgaW5zZXJ0KGxsIHZhbCxsbCByKQp7CiAgICBsbCBub3c7CiAgICB0cmllICpjdXJyPXJvb3Q7CiAgICBmb3IobGwgaT0yMDtpPj0wO2ktLSkKICAgIHsKICAgICAgICBub3c9bWluKDEsdmFsJigxPDxpKSk7CiAgICAgICAgaWYoY3Vyci0+Yml0W25vd109PU5VTEwpCiAgICAgICAgewogICAgICAgICAgICB0cmllICp0ZW1wPW5ldyB0cmllKCk7CiAgICAgICAgICAgIGN1cnItPmJpdFtub3ddPXRlbXA7CiAgICAgICAgICAgIGN1cnI9dGVtcDsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgICAgICBjdXJyPWN1cnItPmJpdFtub3ddOwogICAgICAgIGN1cnItPlI9bWluKGN1cnItPlIscik7CiAgICB9Cn0KaW5saW5lIGxsIHF1ZXJ5KGxsIHZhbCxsbCBsKQp7CiAgICBsbCBub3csbG9va2ZvcixhbnM9MDsKICAgIHRyaWUgKmN1cnI9cm9vdDsKICAgIGZvcihsbCBpPTIwO2k+PTA7aS0tKQogICAgewogICAgICAgIG5vdz1taW4oMSx2YWwmKDE8PGkpKTsKICAgICAgICBsb29rZm9yPTFebm93OwogICAgICAgIC8vdHJ5IGZvciBsb29rZm9yCiAgICAgICAgaWYoY3Vyci0+Yml0W2xvb2tmb3JdIT1OVUxMKQogICAgICAgIHsKICAgICAgICAgICAgaWYoY3Vyci0+Yml0W2xvb2tmb3JdLT5SPGwpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGFucys9KDE8PGkpOwogICAgICAgICAgICAgICAgY3Vycj1jdXJyLT5iaXRbbG9va2Zvcl07CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvL2kgY291bGQgbm90IGdldCBsb29rZm9yCiAgICAgICAgLy9zbyB0cnkgZm9yIG5vdwogICAgICAgIGlmKGN1cnItPmJpdFtub3ddIT1OVUxMKQogICAgICAgIHsKICAgICAgICAgICAgaWYoY3Vyci0+Yml0W25vd10tPlI8bCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY3Vycj1jdXJyLT5iaXRbbm93XTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAwOwogICAgfQogICAgcmV0dXJuIGFuczsKfQppbnQgbWFpbigpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgY2luPj5uOwogICAgZm9yKGxsIGk9MDtpPG47aSsrKQogICAgICAgIGNpbj4+YXJbaV07CiAgICBsbCBzdW0sYW5zPS0xZTE4OwogICAgZm9yKGxsIGk9MDtpPG47aSsrKQogICAgewogICAgICAgIHN1bT0wOwogICAgICAgIGZvcihsbCBqPWk7ajxuO2orKykKICAgICAgICB7CiAgICAgICAgICAgIHN1bSs9YXJbal07CiAgICAgICAgICAgIGFucz1tYXgoYW5zLHF1ZXJ5KHN1bSxpKSk7CiAgICAgICAgICAgIGluc2VydChzdW0saik7CiAgICAgICAgfQogICAgfQogICAgY291dDw8YW5zOwogICAgcmV0dXJuIDA7Cn0=