#include <stdio.h>

struct Dice
{
	int n[6];
};

Dice InputDice()
{
	Dice d;
	for(int i = 0; i < 6; ++i)
	{
		scanf("%d", &d.n[i]);
	}
	
	return d;
}

Dice SetDice(int a, int b, int c, int d, int e, int f)
{
	Dice dice;
	dice.n[0] = a;
	dice.n[1] = b;
	dice.n[2] = c;
	dice.n[3] = d;
	dice.n[4] = e;
	dice.n[5] = f;
	
	return dice;
}

Dice Roll(Dice dice, char dir)
{
	switch(dir)
	{
		case 'N':
			return SetDice(dice.n[1], dice.n[5], dice.n[2], dice.n[3], dice.n[0], dice.n[4]);
		case 'S':
			return SetDice(dice.n[4], dice.n[0], dice.n[2], dice.n[3], dice.n[5], dice.n[1]);
		case 'W':
			return SetDice(dice.n[2], dice.n[1], dice.n[5], dice.n[0], dice.n[4], dice.n[3]);
		case 'E':
			return SetDice(dice.n[3], dice.n[1], dice.n[0], dice.n[5], dice.n[4], dice.n[2]);
	}
}

bool IsSame(Dice a, Dice b)
{
	for(int i = 0; i < 6; ++i)
	{
		if(a.n[i] != b.n[i])
		{
			return false;
		}
	}
	
	return true;
}

bool IsEqual(Dice a, Dice b)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		b = Roll(b, cmd[i]);
		if(IsSame(a, b))
		{
			return true;
		}
	}
	
	return false;
}

int FindSide(Dice a, int top, int front)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		a = Roll(a, cmd[i]);
		if(a.n[0] == top && a.n[1] == front)
		{
			return a.n[2];
		}
	}
	
	return -1;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	Dice D[128];
	bool ans = true;
	for(int i = 0; i < N; ++i)
	{
		D[i] = InputDice();
		
		for(int j = 0; j < i && ans; ++j)
		{
			if(IsEqual(D[i], D[j]))
			{
				ans = false;
			}
		}
	}
	
	if(ans)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
    return 0;
}


#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL a[2000222],dp[4],n,sum[2000222];
#define P(x) (x%3+3)%3
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		sum[i]=sum[i-1];
		if(i&1)sum[i]+=a[i];
	}
	dp[1]=0;dp[2]=max(a[1],a[2]);
	for(int i=3;i<=n;++i)
	{
		LL now,pre1,pre2;
		now=P(i);pre1=P(i-1);pre2=P(i-2);
		dp[now]=0;
		if(i&1)
		{
			dp[now]=max(dp[pre1],dp[pre2]+a[i]);
		}
		else
		{
			dp[now]=max(sum[i],dp[pre2]+a[i]);
		}
	}
	printf("%lld\n",dp[P(n)]);
}