#include <bits/stdc++.h>

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }



int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
		//  ======= FAST I/O =========
	fastio;
	//  ==========================
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	vector<vector<ll>> dp(200005, vector<ll>(3, -INF));
	dp[0][0] = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j < 3; ++j)
			if(i)
				dp[i + 1][j] = max(dp[i + 1][j], dp[i - 1][j] + a[i]);
		for (int j = 0; j < 2; ++j)
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
	
	}
	cout << dp[n+1][1 + n % 2];
	return 0;
}
