#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

long long int score[2001][2001];
long long int const INF = 1000000000000000;

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i <= 2000; i++){
		for(int j = 0; j <= 2000; j++){
			score[i][j] = -INF;
		}
	}
	
	for(int i = 0; i < N; i++){
		cin >> score[0][i];
	}
	
	for(int i = 1; i < N; i++){
		if(i % 2 == 0){
			for(int j = 0; j < N; j++){
				score[i][j] = max(score[i - 1][j] + score[0][(j + i) % N], score[i - 1][(j + 1) % N] + score[0][j]);
			}
		}else{
			for(int j = 0; j < N; j++){
				if(score[0][j] < score[0][(j + i + 1) % N]){
					score[i][(j + 1) % N] = max(score[i][(j + 1) % N], score[i - 1][(j + 1) % N]);
				}else{
					score[i][j] = max(score[i][j], score[i - 1][(j + 1) % N]);
				}
			}
		}
	}
	/*
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << score[i][j] << " ";
		}
		cout << endl;
	}
	*/
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		ans = max(ans, score[N - 1][i]);
	}
	
	cout << ans << endl;
	
	return 0;
}