#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

long long dp[2005][2005];
int n, a[2005];

void p(){
  REP(i,0,n){
    REP(j,0,n){
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}

long long dfs(int sta, int end, int left){
  if(dp[sta][end] != -1) return dp[sta][end];

  if(left == 1){
    if(left%2 != n%2) {  /*not JOI turn*/
      return dp[sta][end] = 0;
    }else{
      return dp[sta][end] = a[sta];
    }
  }

  if(left%2 != n%2){  /*not JOI turn*/
    if(a[sta] < a[end]){
      return dp[sta][end] = dfs(sta, (end+1)%n, left-1);
    }else{
      return dp[sta][end] = dfs((sta-1+n)%n, end, left-1);
    }
  }else{
    return dp[sta][end] = max(dfs((sta-1+n)%n, end, left-1) + a[sta], dfs(sta, (end+1)%n, left-1) + a[end]);
  }

}

int main() {
  cin>>n;
  REP(i,0,n) cin>>a[i];

  REP(i,0,n)REP(j,0,n) dp[i][j] = -1;

  vector<long long> v;
  REP(i,0,n) v.push_back( dfs(i,(i+1)%n,n) );

  cout<<*max_element(v.begin(), v.end())<<endl;

  //p();

  return 0;
}