#include <bits/stdc++.h>

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)

const int inf = 3e18;

int dp[2010][2010];

int N, A[2010];

int rec(int l, int r, int k=0)
{
	if (k == N) return 0;
	
	int &res = dp[l][r];
	
	if (res != -1) return res;
	
	int nl = (l - 1 < 0 ? N - 1 : l - 1);
	int nr = (r + 1 >= N ? 0 : r + 1);
	
	if (k % 2 == 0) {
		res = max(rec(nl, r, k + 1) + A[l], rec(l, nr, k + 1) + A[r]);
	} else {
		if (A[l] < A[r]) res = rec(l, nr, k + 1);
		else res = rec(nl, r, k + 1);
	}
	
	return res;
}

signed main()
{
	cin >> N;
	
	rep(i, N) cin >> A[i];
	
	int ma = 0;
	
	memset(dp, -1, sizeof(dp));
	
	rep(i, N) {
		ma = max(ma, rec((i-1<0?N-1:i-1), (i+1==N?0:i+1),1) + A[i]);
	}
	
	cout << ma << endl;
}