import sys import numpy as np N = int(input()) V = np.array([0]+[int(i) for i in input().split(" ")]+[0,0]) V_MAX = np.zeros_like(V) for i in range(V.shape[0]-4,-1,-1): V_MAX[i] = V[i]+max(V_MAX[i+2],V_MAX[i+3]) print(V_MAX[0])