#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) ((a > b) ? a : b)
long a[200000] = {}, sum[200000 + 2] = {}, isum[200000 + 2] = {};

void init(int n) {
  for (int i=0; i<n; i++) {
    sum[i+2] = sum[i]+a[i];
    isum[n-i-1] = isum[n-i+1] + a[n-i-1];
  }
}

long ans(int n, int m, int st) {
  long res = 0;
  if (n%2 == 0) {
    for (int i=0; i<=n/2; i++) {
      long tmp = sum[st+2*i]-sum[st] + isum[st+2*i+1];
      res = Max(res, tmp);
    }
    return res;
  } else {
    if (m == 0)
      return 0;
    res = isum[st+2];
    long tmp = a[st] + ans(n-2, m-1, st+2);
    res = Max(res, tmp);
    tmp = a[st+1] + ans(n-3, m-1, st+3);
    res = Max(res, tmp);
    return res;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i=0; i<n; i++)
    scanf("%ld", a+i);
  init(n);
  printf("%ld\n", ans(n, n/2, 0));
  return 0;
}
