#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll memo[2020][2020];
int n;
vector<int> a;

ll rec(int l, int len){
  if(l>=n)l-=n;
  if(memo[l][len]>0)return memo[l][len];
  if(len <= 1)return 0;

  int L = l, R = l+len-1;
  if(R>=n)R-=n;
  if(a[L]<a[R]){
    R--; if(R<0)R+=n;
  }else{
    L++; if(L>=n)L-=n;
  }

  return memo[l][len] = max(rec(L+1,len-2)+a[L], rec(L,len-2)+a[R]);
}

int main(){
  scanf("%d",&n);
  a.resize(n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  ll res = 0;
  for(int i=0;i<n;i++){
    res = max( res, rec(i+1,n-1) + a[i] );
  }
  printf("%lld\n",res);
}