#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <unordered_map>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(18) + 10;
const int mod = TEN(9) + 10;

int N;
unordered_map<int, int> dp[200010]; // dp[i][j] := 2飛ばしをj回使った,3飛ばしをk回使った

signed main()
{
	cin >> N;

	vi A(N + 5);
	rep1(i, N) cin >> A[i];

	int mx = -inf;

	dp[1][1] = A[1];
	dp[2][1] = A[2];

	int len = N % 2 == 0 ? 3 : 4;

	for (int i = 1; i <= N; ++i) {
		for (pii p : dp[i]) {
			int j = p.fst;
			for (int k = 2; k <= len; ++k) {
				if (j + k <= (N + 1 / 2)) {
					chmax(dp[i + k][j + 1], dp[i][j] + A[i + k]);
				}
			}
		}
	}

	cout << dp[N][N / 2] << endl;
}


