#include <iostream>
#include <vector>
#include <queue>
#include <iostream>
#include <bitset>
#include <cmath>


using namespace std;
typedef long long LL;

int main() {

    LL ans = 0;
    int N; cin >> N;
    LL a[200000+1];
    LL dp[3][200000+1];

    for(int i = 1; i <=N; i++){
        cin >> a[i];
    }

    // N % 2 == 0
    for(int i = 0; i < (2+N % 2);i++){
        for(int j =1; j <= N;j+=2){
            if(i==0 && j==1){
                dp[i][i+j] = a[i+j];
                continue;
            }
            if(i==0){
                dp[i][i+j] = dp[i][i+j-2]+a[i+j];
                continue;
            }
            if(j==0){
                dp[i][i+j] = a[i+j];
                continue;
            }
            dp[i][i+j] = max(dp[i][i+j-2]+a[i+j], dp[i-1][i+j-3]+a[i+j]);
        }
        // cout << N % 2 << endl;
    }
 
    

    // a[i];
    for(int i = 0; i <=2; i++){
        for(int j = 0; j <=N; j++){
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    for(int i=0; i <=2;i++){
        // cout << dp[i][i+N-((N+1)%2)] << endl;
        ans = max(ans,dp[i][i+N-((N+1)%2)]);
    }

    cout << ans << endl;
}