#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector <ll> a(n+1), dp[3];
	for (int i=0; i<=2; i++) {
		dp[i].resize(n+1);
		for (int j=1; j<=n; j++) {
			dp[i][j] = -1e18;
		}
	}
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	for (int i=1; i<=n; i++) {
		for (int j=0; j<=2; j++) {
			if (i-j-2 < 1) continue;
			for (int k=0; k<=2-j; k++) {
				dp[j+k][i] = max(dp[j+k][i], dp[k][i-j-2]+a[i]);
			}
		}
		if (i <= 3) {
			dp[max(0, i-2)][i] = a[i];
		}
	}
	ll ans;
	if ((n&1)) {
		ans = max(max(max(dp[1][n], dp[2][n]), max(dp[0][n-1], dp[1][n-1])), dp[0][n-2]);
	} else {
		ans = max(dp[1][n], max(dp[0][n], dp[0][n-1]));
	}
	cout << ans;
	return 0;
}

#include <iostream>
using namespace std;
#define el '\n'
typedef long long ll;
const int MAXN = 2e5+2;
int N, A[MAXN];
ll odd[MAXN], dp[MAXN];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N;
	for(int i = 1;i<=N;i++) cin >> A[i];
	odd[1] = A[1];
	for(int i = 2;i<=N;i++){
		if(i%2){
			odd[i] = odd[i-2]+A[i];
		}
	}
	dp[1] = 0;
	for(int i = 2;i<=N;i++){
		if(i%2){
			dp[i] = max(dp[i-2]+A[i], dp[i-1]);
		}else{
			dp[i] = max(dp[i-2]+A[i], odd[i-1]);
		}
	}
	cout << dp[N] << el;
}