/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author zjsdut
 */

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
struct fast_ios {
  fast_ios() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  std::cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using vi = std::vector<int>;
using pii = std::pair<int, int>;
using pli = std::pair<ll, int>;
template <typename T> using vv = std::vector<std::vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(std::unique(all(vec)), std::end(vec))
#define LB(cont, x) int(std::lower_bound(all(cont), x) - std::begin(cont))
#define UB(cont, x) int(std::upper_bound(all(cont), x) - std::begin(cont))

template <typename T>
std::ostream &operator<<(std::ostream &stream, const std::vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const std::vector<T> &t) {
  std::cout << t << '\n';
}

template <typename T> void print(const std::vector<std::vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { std::cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { std::cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}
using namespace std;

class FSelectHalf {
  static void SOLVE() {
    int n;
    scan(n);
    vi a(n);
    scan(a);
    vv<ll> dp(n, vl(2));

    dp[n-1][1] = a[n-1];
    for (int i = n - 3; i >= 0; i -= 2) {
      dp[i][1] = a[i] + dp[i + 2][1];
    }

    // dp[i][0]：从a[i..n)上选择(n-i)/2个数且相邻两数不能都选，所选的数和的最大值。
    dp[n-1][0] = 0;
    dp[n-2][0] = max(a[n-1],a[n-2]);

    down (i, n - 3, 0) {
      int len = n - i;
      dp[i][0] = max(a[i] + dp[i + 2][0], dp[i + 1][(len % 2 == 0 ? 1 : 0)]);
    }
    println(dp[0][0]);
  }

public:
  static void solve(std::istream &in, std::ostream &out) {
    auto cin_buff = std::cin.rdbuf(in.rdbuf());
    auto cerr_buff = std::cerr.rdbuf(std::cout.rdbuf(out.rdbuf()));
    SOLVE();
    std::cout.rdbuf(std::cerr.rdbuf(cerr_buff));
    std::cin.rdbuf(cin_buff);
  }
};


int main() {
  FSelectHalf solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 15076