#include<iostream>
#include<utility>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll dp[2010][2010]={0},in[2020],n,out;
queue<pii>q;
int main(){
	cin>>n;rep(i,n)cin>>in[i];
	rep(i,n)dp[i][1]=in[i],q.push(pii(i,1));
	while(!q.empty()){
		pii r=q.front();q.pop();
		int a=r.first,b=r.second;
		int s=a-1,t=(s+1+b)%n;
		if(s==-1)s=n-1;
		if(b%2){
			if(in[s]<in[t])s=a;
			if(dp[s][b+1]<dp[a][b]){
				dp[s][b+1]=dp[a][b];
				if(b+1!=n)q.push(pii(s,b+1));
			}
		}else{
			rep(i,2){
				if(dp[s][b+1]<dp[a][b]+in[(i?t:s)]){
					dp[s][b+1]=dp[a][b]+in[(i?t:s)];
					if(b+1!=n)q.push(pii(s,b+1));
				}
				s=a;
			}
		}
	}
	rep(i,n)out=max(out,dp[i][n]);
	cout<<out<<endl;
}