#include <vector>
#include <iostream>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int main()
{
	int n; scanf("%d", &n);

	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	vector<vector<long long> > dp(n, vector<long long>(n, 0)); // [i, j]

	for (int i = 0; i < n; i++)
	{
		dp[0][i] = a[i];
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i % 2)
			{
				if (a[j] > a[(j + i + 1) % n])
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][(j + 1) % n]);
				}

				if (a[(j + i) % n] > a[(j + n - 1) % n])
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][j]);
				}
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j] + a[(j + i) % n], dp[i - 1][(j + 1) % n] + a[j]);
			}
		}
	}

	long long ret = 0;

	for (int i = 0; i < n; i++)
	{
		ret = max(ret, dp[n - (2 - n % 2)][i]);
	}

	printf("%lld\n", ret);

	return 0;
}