using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var suffix = 0L;
        for (int i = 1 + n % 2; i < seqA.Length; i += 2)
        {
            suffix += seqA[i];
        }

        var max = suffix;
        var ps = new long[2];
        for (int i = 2; i < seqA.Length; i += 2)
        {
            var window = seqA.AsSpan(i - 2, 3);
            suffix -= window[2];
            ps[0] = ps.Max() + window[1];
            ps[1] += window[0];
            max = Math.Max(max, ps.Max() + suffix);
        }

        Console.WriteLine(max);
    }
}
