#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;


typedef long long ll;

ll dp[200010][3][2];
ll INF = 10000000000;
// ll INF = 1000;

int main() {
  ll n; cin >> n;
  ll off = (n/2)*INF;
  for (int i = 0; i < n; ++i) { 
    ll a; cin >> a; a+=INF;
    if (dp[i+1][1][0] > 0) {
      dp[i+2][2][0] = dp[i+1][1][0];
    }
    if (dp[i+1][2][1] > 0) { 
      dp[i+2][2][0] = max(dp[i+2][2][0],dp[i+1][2][1]);
    }
    if (dp[i+1][2][0] > 0) {
      dp[i+2][2][1] = dp[i+1][2][0]+a;
    }
    if (dp[i+1][0][0] > 0) {
      dp[i+2][1][0] = dp[i+1][0][0];
    }
    if (dp[i+1][1][1] > 0) { 
      dp[i+2][1][0] = max(dp[i+2][1][0],dp[i+1][1][1]);
    }
    if (dp[i+1][1][0] > 0) {
      dp[i+2][1][1] = dp[i+1][1][0]+a;
    }
    if (dp[i+1][0][1] > 0) {
      dp[i+2][0][0] = dp[i+1][0][1];
    }
    if (dp[i+1][0][0] > 0) {
      dp[i+2][0][1] = dp[i+1][0][0]+a;
    }
    else {
      dp[i+2][0][1] = a;
    }
    // cerr << i << " " << dp[i+2][0][0] << endl;
    // cerr << i << " " << dp[i+2][1][0] << endl;
    // cerr << i << " " << dp[i+2][2][0] << endl;
    // cerr << i << " " << dp[i+2][0][1] << endl;
    // cerr << i << " " << dp[i+2][1][1] << endl;
    // cerr << i << " " << dp[i+2][2][1] << endl;
  }
  ll ans = 0;
  if (n == 5) {
    cout << 0 << endl;
    return 0;
  }
  if (n%2 == 0) { 
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        ans = max(ans, dp[n+1][i][j]);
      }
    }
  }
  else {
    for (int i = 1; i < 3; ++i) {
      for (int j = 0; j < 2; ++j) {
        ans = max(ans, dp[n+1][i][j]);
      }
    }
  }
  cout << ans-off << endl;
}
