#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
// #define NMAX 1000000000

using VL = vector<ll>;
using VVL = vector<VL>;
using TPL = tuple<ll,set<int>>; // <value,{index}>
using VT = vector<TPL>;

ll INF = LLONG_MAX>>2;

int N;
VL A;
ll ans;

ll solve(){

	VVL dp(N/2+2, VL(N+2, -INF)); // dp[j][i]

	rp(i,1,N+1) dp[1][i] = A[i-1];

	rp(i, 2, N+1){
		ll a = A[i-1];
		int j = i/2;
		dp[j][i] = max(dp[j][i], dp[j-1][i-2] + a);
		dp[j][i] = max(dp[j][i], dp[j][i-1]);
	}

	// cout<<"   ";//
	// rp(i,0,dp[0].size())printf("%2d ",i);puts("");//
	// rp(i,0,dp.size()){
	// 	cout<<i<<": ";
	// 	rp(j,0,dp[i].size()){
	// 		if(dp[i][j]==-INF) cout<<"-- ";
	// 		else printf("%2lld ",dp[i][j]);
	// 	}puts("");
	// }puts("---");

	return dp[N/2][N];
}

int main(){
	cin>>N;
	A.resize(N);
	rp(i, 0, N) cin>>A[i];
	cout<< solve() <<endl;
}
