// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1) {

  cerr << name << " : " << arg1 << "\n";

}

template <typename Arg1, typename... Args>

void __f(const char* na, Arg1&& arg1, Args&&... args) {

  const char* c = strchr(na + 1, ',');

  cerr.write(na, c - na) << " : " << arg1 << " , ";

  __f(c + 1, args...);

}

#define endl "\n"

#define all(v) v.begin(), v.end()

#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())

typedef long long LL;

typedef pair <int,int> pii;

const double pi = acos(-1.0);

const double eps = 1e-8;

const int mod = 1e9 + 7;

const int inf = 1e9;

const LL INF = 1e16;

const int N = 2e5 + 5;



map <LL,LL> dp[ N ];

int n;

LL a[ N ];



LL solve(int idx, int taken) {

  int need = n/2 - (n - idx + 1)/2;

  if (taken < need) return -INF;

  if (idx >= n) return taken == n/2 ? 0 : -INF;

  if (dp[idx].count(taken)) return dp[idx][taken];

  LL ret = -INF;

  ret = max(ret, solve(idx + 2, taken + 1) + a[idx]);

  ret = max(ret, solve(idx + 1, taken));

  return dp[idx][taken] = ret;

}

int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(0); cout.tie(0);

  #ifdef LOCAL

    freopen("input.txt", "r", stdin);

  #endif // LOCAL

  cin >> n;

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

  cout << solve(0, 0) << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.5995855270835586x):
/*

 * Author : Andrew J

*/

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define pb push_back

using ll = long long;

typedef pair <ll , ll> ii;

void in(ll &x);

const ll N = 2e5 + 10;

const ll inf = 1e16;

ll n;

ll a[N],dp1[N][2],dp2[N][2];



ll fltor(ll cur , bool lr) {

   // lr = 0, terakhir ambil kiri otherwise kanan

   if (cur > n) return 0;

   ll &sol = dp1[cur][lr];

   if (sol != -1) return sol;

   if (lr) {

      sol = fltor(cur + 2 , 1) + a[cur + 1];

   } else {

      sol = max(fltor(cur + 2 , 0) + a[cur] , fltor(cur + 2 , 1) + a[cur + 1]);

   }

   return sol;

}



ll frtol(ll cur , bool lr) {

   // lr = 0, trakhir ambil kiri

   // lr = 1, trakhir ambil kanan

   if (cur <= 0) return 0;

   ll &sol = dp2[cur][lr];

   if (sol != -1) return sol;

   if (lr) {

      sol = max(frtol(cur - 2 , 0) + a[cur - 1] , frtol(cur - 2 , 1) + a[cur]);

   } else {

      sol = frtol(cur - 2 , 0) + a[cur - 1];

   }

   return sol;

}



int main() {

   memset (dp1 , -1 , sizeof dp1);

   memset (dp2 , -1 , sizeof dp2);

   in(n);

   for (ll i = 1 ; i <= n ; i++) {

      in(a[i]);

   }

   if (n & 1) {

      ll sol = LLONG_MIN;

      for (ll i = 1 ; i <= n ; i += 2) {

         ll cur = fltor(i + 1 , 0);

         cur += frtol(i - 1 , 1);

         sol = max(sol , cur);

      }

      printf("%lld\n" , sol);

   } else {

      printf("%lld\n" , fltor(1 , 0));

   }

   return 0;

}



void in(ll &x) {

	bool neg = false;

	register ll c;

	x = 0;

	c = getchar();

	if(c == '-') {

		neg = true;

		c = getchar();

	}

	for (; c > 47 && c < 58; c = getchar())

   	x = (x << 1) + (x << 3) + c - 48;

	if (neg) x *= -1;

}