#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const ll INF = 1e18;
const int MOD = 1000000007;
// const int MOD = 998244353;

ll dp[200005][5];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int k = 1 + n % 2;
   rep(i, 0, n + 1) rep(j, 0, k + 1) dp[i][j] = -INF;
   dp[0][0] = 0;
   rep(i, 0, n) {
      rep(j, 0, k + 1) {
         chmax(dp[i + 1][j + 1], dp[i][j]);
         ll now = dp[i][j];
         if ((i + j) % 2 == 0) now += a[i];
         chmax(dp[i + 1][j], now);
      }
   }
   ll ans = dp[n][k];
   cout << ans << endl;
   return 0;
}
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<vector<long>> d(n + 1, vector<long>(5, LLONG_MIN));
    d[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 5; j++) {
            int k = (i + 1) / 2 - j;
            if (k < 0) continue;
            {
                // don't take i-th
                int ii = i - 1;
                int jj = (ii + 1) / 2 - k;
                if (jj >= 0 && jj < 5) {
                    if (d[ii][jj] != LLONG_MIN) {
                        d[i][j] = max(d[i][j], d[ii][jj]);
                    }
                }
            }
            if (k > 0) {
                // take i-th, don't take i-1-th
                int ii = i == 1 ? 0 : i - 2;
                int jj = (ii + 1) / 2 - (k - 1);
                if (jj >= 0 && jj < 5) {
                    if (d[ii][jj] != LLONG_MIN) {
                        d[i][j] = max(d[i][j], d[ii][jj] + a[i - 1]);
                    }
                }
            }
        }
    }
    int k = n / 2;
    int j = (n + 1) / 2 - k;
    cout << d[n][j];

    return 0;
}