#include <stdio.h>
#include <stdlib.h>
#define MAX(x,y) ((x)<(y)?(y):(x))
 
typedef long long ll;
const ll INF = 1LL << 60;
 
int main(){
    int N;
    scanf("%d",&N);
    ll A[N];
    for(int i = 0;i<N;i++) scanf("%lld ",&A[i]);
    ll dp[N+1][N/2];
    for(int i = 0;i<N/2;i++) dp[2*i][i] = (0LL-INF);
    for(int j = 0;j<N/2;j++){
        for(int i = 2*j+1;i<2*j+4&&i<N+1;i++){
            if(j==0) dp[i][j]=MAX(dp[i-1][j],A[i-1]);
            else if(j>0) dp[i][j]=MAX(dp[i-1][j],dp[i-2][j-1]+A[i-1]);
        }
    }
  	printf("%lld\n",dp[N][N/2-1]);
    return 0;
}