from collections import defaultdict N = int(input()) V = list(map(int, input().split())) cache = defaultdict(int) for n in range(N): cache[n] = max(cache[n-1], cache[n-2]+ V[n]) print(cache[n])