#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll idx = 0;
	vector<vector<ll>> dp(N + 2, vector<ll>(3, -INF));
	dp[0][0] = 0;
	REP(i, N) {
		REP(j, 3) {
			if (dp[i][j] != -INF) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				dp[i + 2][j + 1] = max(dp[i + 2][j + 1], dp[i][j] + A[i]);
			}
		}

		if (2 < i && IsOdd(i)) {
			REPN(j, 1, 3) {
				ll sftIdx = i + j;
				dp[sftIdx][0] = dp[sftIdx][1];
				dp[sftIdx][1] = dp[sftIdx][2];
				dp[sftIdx][2] = -INF;
			}
			idx++;
		}
	}

	ll ofs = N / 2 - idx;
	ll ans = max(dp[N][ofs], dp[N + 1][ofs]);
	cout << ans << endl;
	return 0;
}
