from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
dp = [0] * n
if n % 2:
    ret2 = 0
    dp2 = [0] * n
    dp2[0] = A[0]
    dp2[1] = A[1]
    for i in range(n):
        if i == 0:
            ret = 0
        elif i == 1:
            ret = A[1]
        elif i >= 2:
            dp2[i] = dp2[i - 2] + A[i]
            ret = max(ret, dp[i - 2] + A[i])
        elif i >= 3:
            ret = max(ret, dp[i - 3] + A[i])
        elif i >= 4:
            ret = max(ret, dp2[i - 4] + A[i])
        dp[i] = ret
    print(max(dp[-1], dp[-2], dp[-3]))
else:
    for i in range(n):
        ret = A[i]
        if i >= 2:
            ret = max(ret, dp[i - 2] + A[i])
        elif i >= 3:
            ret = max(ret, dp[i - 3] + A[i])
        dp[i] = ret
    print(max(dp[-1], dp[-2]))




