import core.stdc.stdio;
import std.algorithm;

void main(){
	int n;
	scanf("%d",&n);
	int[] a = new int[n];
	foreach(ref v;a)
		scanf("%d",&v);
	long[][] dp = new long[][](n,n);
	int l = n%2;
	if(l)
		foreach(i;0..n)
			dp[0][i]=a[i];
	foreach(s;1..n){
		l^=1;
		foreach(i;0..n)
			if(l)
				dp[s][i]=max(dp[s-1][i]+a[(i+s)%n],dp[s-1][(i+1)%n]+a[i]);
			else
				dp[s][i]=a[(i+s)%n]>a[i]?dp[s-1][i]:dp[s-1][(i+1)%n];
	}
	long ans;
	foreach(d;dp[n-1])
		ans=max(d,ans);
	printf("%lld\n",ans);
}