#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define ARR_MAX 200000
#define BUF_SIZE (11*ARR_MAX+100)

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int64_t *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtoll(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    int num = get_int();
    int64_t arr[ARR_MAX];
    int i, j;
    int64_t ans = 0;

    fget_array(arr, num);
    if(!(num%2)) {
        int64_t sum1 = 0;
        int64_t sum2 = 0;
        for(i = 0; i < num; i+=2) {
            sum1 += arr[i];
        }
        for(i = 1; i < num; i+=2) {
            sum2 += arr[i];
        }
        if(!(num%2)) {
            ans = max(sum1, sum2);
            goto finish;
        }
    }
    // assume that num is odd number
    // sum2: move edge
    // static int64_t cum[ARR_MAX+1];
    // static int64_t cum2[ARR_MAX+1];
    // for(i = 1; i <= num; i++) {
    //     int64_t elem = arr[i-1];
    //     cum[i] = cum[i-1] + elem;
    //     cum2[i] = cum2[i-1] + (i%2==0)*elem; // even sum
    // }
    // 1-indexed
    static int64_t dp[ARR_MAX+1][3];
    static int64_t dp_rev[ARR_MAX+1][3];
    for(i = 2; i < num; i+=2) {
        dp[i][0] = dp[i-2][0] + arr[i-2];
        dp[i][1] = max(dp[i-2][0], dp[i-2][1])+arr[i-1];
        dp[i][2] = max(dp[i][0], dp[i][1]);
    }
    for(i = 2; i < num; i+=2) {
        dp_rev[i][0] = dp_rev[i-2][0] + arr[num-i+1];
        dp_rev[i][1] = max(dp[i-2][0], dp_rev[i-2][1])+arr[num-i];
        dp_rev[i][2] = max(dp_rev[i][0], dp_rev[i][1]);
    }

    for(i = 0; i < num; i+=2) {
        // split [0, i), i, [i+1, num)
        int64_t sum1 = dp[i][2];
        int64_t sum2 = dp_rev[num-1-i][2];
#ifdef DEBUG
        printf("[pivot: %lld]: %lld+%lld\n", arr[i], sum1, sum2);
#endif
        ans = max(ans, sum1+sum2);
    }

finish:
    printf("%llu\n", ans);
    return 0;
}