#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

ll solve(int n,int k,vector<int>a){
    ll dp1[2][k+1];
    ll dp2[2][k+1];
    memset(dp1,0,sizeof(dp1));
    memset(dp2,0,sizeof(dp2));
    int mx=-1e9;
    int now=1,old=0;
    for(int i=0;i<n;i++){
        old=now;
        now=1-now;
        dp1[now][1]=a[i];
        dp2[now][1]=mx;
        mx=max(mx,a[i]);
     for(int j=0;j<=k;j++){
       if(j>(i+1)/2)continue;
       if(j==0)continue;
       if(old>0)dp1[now][j]=dp2[old][j-1]+a[i];
       if(old>0)dp2[now][j]=max(dp1[old][j],dp2[old][j]);
    }
    }
    return max(dp1[now][k],dp2[now][k]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

int n;
cin>>n;
int k=n/2;

vector<int>a(n);
rep(i,n)cin>>a[i];

cout<<solve(n,k,a)<<endl;
return 0;
}