#include<cstdio>
#include<cstdlib>
int main(void){
	long long a[2000];
	int n;
	long long dp[2000];
	long long dq[2000];
	int x,y;
	long long ans;
	for (int i = 0; i < 2000; i++){
		a[i] = 0;
		dp[i] = 0;
		dq[i] = 0;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n; i++){
		if (i % 2 == 1){
			for (int j = 0; j < n; j++){
				x = (i + j) % n;
				y = (j + n - 1) % n;
				if (a[x] < a[y]){
					if (dq[y] < dp[j])dq[y] = dp[j];
				}
				else{
					if (dq[j] < dp[j])dq[j] = dp[j];
				}
			}
		}
		else{
			for (int j = 0; j < n; j++){
					x = (i + j) % n;
					y = (j + 1) % n;
					dq[j] = dp[j] + a[x];
					if (dq[j] < dp[y] + a[j])dq[j] = dp[y] + a[j];
				}
			}
		for (int j = 0; j < n; j++){
			dp[j] = dq[j];
			dq[j] = 0;
		}
		}
	ans = 0;
	for (int i = 0; i < n; i++){
		if (ans < dp[i])ans = dp[i];
	}
	printf("%lld\n", ans);

	return 0;
	}