#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
LL pres[MAXN],sufs[MAXN],pre[MAXN],suf[MAXN];
int n;LL a[MAXN];
int main()
{
	n=read();LL S=0;
	for(int i=1;i<=n;i++)a[i]=read(),S+=a[i],pre[i]=pre[i-1]+a[i];
	for(int i=1;i<=n;i++)pres[i]=pres[i-1]+((i&1)?a[i]:0);
	for(int i=n;i>=1;i--)sufs[i]=sufs[i+1]+(((n-i+1)&1)?a[i]:0),suf[i]=suf[i+1]+a[i];
	if(!(n&1))pr2(max(S-pres[n],pres[n]));
	else
	{
		LL ans=-1e18;
		for(int i=1;i+2<=n;i++)
		{
			LL s1=(i&1)?pres[i]:pre[i]-pres[i];
			LL s2=((n-(i+3)+1)&1)?sufs[i+3]:suf[i+3]-sufs[i+3];
			
			chkmax(ans,s1+s2);
		}
		chkmax(ans,pres[n-1]);
		chkmax(ans,sufs[2]);
		chkmax(ans,S-pres[n]);
		pr2(ans);
	}
	return 0;
}

