N = int(input()) V = list(map(int, input().split())) yummy = [0] * N yummy[0] = V[0] if N < 2: print(yummy[0]) else: yummy[1] = max(V[0], V[1]) for i in range(2, N): yummy[i] = max(yummy[i-2] + V[i], yummy[i-1], yummy[i-2]) print(yummy[N-1])