#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<18, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n,a[maxn], dp[maxn][3];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) {
		dp[i][0] = a[i] + (i-2>0?dp[i-2][0]:0);
		dp[i][1] = max(a[i] + (i-2>0?dp[i-2][1]:0), a[i] + (i-3>0?dp[i-3][0]:0));
		dp[i][2] = max({a[i] + (i-2>0?dp[i-2][2]:0), a[i] + (i-3>0?dp[i-3][1]:0), a[i] + (i-4>0?dp[i-4][0]:0)});
	}
	ll ans;
	if(n&1) ans = max({dp[n][0], dp[n][1], dp[n][2]});
	else ans = max(dp[n][0], dp[n][1]);
	cout << ans;
	return 0;
}
