#include<bits/stdc++.h>
using namespace std;
using ll = long long;


int main(){

    int n;
    cin>>n;
    vector<int> arr(n+1);

    for(int i = 1; i <= n; i++) cin>>arr[i];

    vector<ll> pf(n+1);
    vector<ll> dp(n+1,LLONG_MIN);
    for(int i = 1; i <= n; i++) if(i&1) pf[i]+=arr[i]+pf[i-2 < 0 ? 0 : i-2]; // pref of odd sum

    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        if(i&1) dp[i] = max(dp[i-1],arr[i]+dp[i-2]); // for odd 
        else dp[i] = max(pf[i-1],dp[i-2]+arr[i]); //for even
    }
    cout<<dp[n];
}

#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define MAXN 200001
#define INF -200000000000000
ll a[MAXN];
ll dp[MAXN][3];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < MAXN; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = INF;
        }
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = a[2];
    dp[1][2] = a[3];
    for (int i = 2; i <= n / 2; i++) {
        dp[i][0] = dp[i - 1][0] + a[i * 2 - 1];
        dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + a[i * 2];
        if (n % 2) dp[i][2] = max(dp[i - 1][2], max(dp[i - 1][1], dp[i - 1][0])) + a[i * 2 + 1];
    }
    if (n % 2) cout << max(max(dp[n / 2][2], dp[n / 2][1]), dp[n / 2][0]) << endl;
    else cout << max(dp[n / 2][1], dp[n / 2][0]) << endl;
    return 0;
}