using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var accumOdd = new long[n + 1];
        var accumEven = new long[n + 1];
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
            {
                accumEven[i + 1] = accumEven[i] + a[i];
                accumOdd[i + 1] = accumOdd[i];
            }
            else
            {
                accumEven[i + 1] = accumEven[i];
                accumOdd[i + 1] = accumOdd[i] + a[i];
            }
        }
        if (n % 2 == 0)
        {
            var res = Max(accumOdd.Last(), accumEven.Last());
            var sum = 0L;
            for (int i = accumEven.Length - 3; i >= 0; i -= 2)
            {
                sum += a[i + 1];
                res = Max(res, accumEven[i] + sum);
            }
            Console.WriteLine(res);
            return;
        }
        else
        {
            var res = Max(accumOdd.Last(), Max(accumEven.SkipLast(1).Last(), accumEven.Last() - a.First()));
            var sum = accumEven.SkipLast(1).Last();
            var tailSum = 0L;
            var tailMax = 0L;
            for (int i = accumEven.Length - 4; i >= 0; i -= 2)
            {
                sum -= a[i];
                sum += a[i + 1];
                tailSum += a[i + 2];
                tailSum -= a[i + 1];
                tailMax = Max(tailMax, tailSum);
                res = Max(res, sum + tailMax);
            }
            Console.WriteLine(res);
            return;
        }
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T Identity;
    T[] Data;
    Func<T, T, T> Merge;
    int LeafCount;

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(int size, T identity, Func<T, T, T> merge)
    {
        Init(size, identity, merge);
        for (int i = 1; i < Data.Length; i++) Data[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(T[] elems, T identity, Func<T, T, T> merge)
    {
        Init(elems.Length, identity, merge);
        elems.CopyTo(Data, LeafCount);
        for (int i = elems.Length + LeafCount; i < Data.Length; i++) Data[i] = identity;
        for (int i = LeafCount - 1; i >= 1; i--) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Init(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        LeafCount = 1;
        while (LeafCount < size) LeafCount <<= 1;
        Data = new T[LeafCount << 1];
    }

    public T this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { return Data[LeafCount + index]; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { Update(index, value); }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Update(int i, T x) { Data[i += LeafCount] = x; while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x) { Data[i += LeafCount] = Merge(Data[i], x); while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int l, int r)
    {
        T lRes = Identity, rRes = Identity;
        for (l += LeafCount, r += LeafCount; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1)
        {
            if ((l & 1) == 1) lRes = Merge(lRes, Data[l]); if ((r & 1) == 0) rRes = Merge(Data[r], rRes);
        }
        return Merge(lRes, rRes);
    }
}


Measured memory_bytes: 49876