#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
int n;
int A[200005];
int dp[200005][3];
int INF = 1e18;
signed main()
{
    sc(n)
    for(int i=1;i<=n;i++)sc(A[i])
    dp[1][0]=A[1];
    dp[1][1]=-INF;
    dp[1][2]=-INF;
    dp[2][0]=A[2];
    dp[2][1]=-INF;
    dp[2][2]=-INF;
    int len = n/2;
    int ans = -INF;
    for(int i=3;i<=n;i++){
        dp[i][0]=dp[i-2][0]+A[i];
        dp[i][1]=max(dp[i-2][1]+A[i],dp[i-3][0]+A[i]);
        if(i>3)
            dp[i][2]=max((dp[i-2][2]+A[i],dp[i-3][1]+A[i]),dp[i-4][0]+A[i]);
        else dp[i][2]=-INF;
        if((i+1)/2 == len){
            ans = max(ans,dp[i][0]);
        }else if((i+2)/2 == len +1){
            ans = max(ans,dp[i][1]);
        }else if((i+3)/2 == len + 2){
            ans = max(ans,dp[i][2]);
        }
    }
    cout<<ans<<'\n';
}
