using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var A = cin.ReadIntArray(N);
			var Res = N % 2 == 0 ? SolveEven(N / 2, A) : SolveOdd(N / 2, A);
			Console.WriteLine(Res);
		}
		public long SolveEven(int halfN, int[] A) {
			var leftest = ER(0, halfN).Sum(j => (long)A[2 * j]);
			var turn = new long[halfN + 1];
			for(int i = halfN; i > 0; i--) {
				turn[i-1] = turn[i] - A[2 * i - 2] + A[2 * i - 1];
			}
			return leftest + turn.Max();
		}

		public long SolveOdd(int halfN, int[] A) {
			var closest = ER(0, halfN).Sum(j => (long)A[2 * j + 1]);
			var leftTurn = new long[halfN + 1];
			var MaxUntil = new long[halfN + 1];	//i-ko
			for(int i = 0; i < halfN; i++) {
				leftTurn[i + 1] = leftTurn[i] + A[2 * i] - A[2 * i + 1];	
			}
			var tmpMaI = 0;
			for(int i = 0; i < halfN; i++) {
				if(leftTurn[tmpMaI] < leftTurn[i + 1]) {
					MaxUntil[i + 1] = leftTurn[i + 1];
					tmpMaI = i + 1;
				} else MaxUntil[i + 1] = MaxUntil[i];
			}
			var rightTurn = new long[halfN + 1];
			for(int i = halfN; i > 0; i--) {
				rightTurn[halfN - i + 1] = rightTurn[halfN - i] - A[2 * i - 1] + A[2 * i];
			}
			var dp = new long[halfN + 1];   //for rightTurns
			for(int i = 0; i <= halfN; i++) {
				dp[i] = rightTurn[i] + MaxUntil[halfN - i];
			}
			return dp.Max() + closest;
		}

		public IEnumerable<int> ER(int start, int count) => Enumerable.Range(start, count);
	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x] = A[y];
			A[y] = tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}


Measured memory_bytes: 53664