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