#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll n;
    cin>>n;
    V a(n);
    rep(i,n)cin>>a[i];
    VVV dp(n+1,VV(n+1,V(2,1e10)));
    rep(i,n){
        for(ll j=max((int)(i/2)-2,0);j<=(i+1)/2;j++){
            if(dp[i][j][0]==1e10){
                if(dp[i][j][1]!=1e10){
                    dp[i+1][j][0]=dp[i][j][1];
                }
            }else{
                if(dp[i][j][1]==1e10){
                    dp[i+1][j][0]=dp[i][j][0];
                }else{
                    dp[i+1][j][0]=max(dp[i][j][0],dp[i][j][1]);
                }
            }
            if(i%2==0 || j!=(i+1)/2){
                if(dp[i][j][0]==1e10){
                    dp[i+1][j+1][1]=a[i];
                }else{
                    dp[i+1][j+1][1]=dp[i][j][0]+a[i];
                }
            }
        }
    }
    cout<<max(dp[n][n/2][0],dp[n][n/2][1])<<endl;
}
