#include <stdio.h>
long long a[1000000];
long long sum1[300000];
long long sum2[300000]; 
long long temp[300000]; 
int main(){
	int n,i,j,last;
	long long max;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	  scanf("%lld",&a[i]);
	sum1[0]=0;
	sum2[0]=0;
	for (i=1;i<=n/2;i++)
	 {sum1[i]=sum1[i-1]+a[2*i-1];
	  sum2[i]=sum2[i-1]+a[2*i];
		 }
	if (n%2==0){
		max=sum2[n/2];
		for (i=1;i<=n/2;i++){
			if (sum1[i]+sum2[n/2]-sum2[i]>max)
			  max=sum1[i]+sum2[n/2]-sum2[i];
		}
		printf("%lld",max);
	}else{
		sum1[n/2+1]=sum1[n/2]+a[n];
		if (sum1[1]<sum2[1]) 
		  {temp[1]=sum2[1];
		   last=0;
		  }else{
		  temp[1]=sum1[1];
		  last=1;
		  }
		for (i=2;i<=n/2;i++){
			if (temp[i-1]+a[i*2]>sum1[i])
				temp[i]=temp[i-1]+a[i*2];else
				  temp[i]=sum1[i];
		}
		max=sum1[n/2+1]-sum1[1];
		for (i=1;i<=n/2;i++)
		  if (temp[i]+sum1[n/2+1]-sum1[i+1]>max)
		    max=temp[i]+sum1[n/2+1]-sum1[i+1];
		printf("%lld",max);
	}
} 