n = int(input()) sushi_plates = list(map(int, input().split())) if n == 1: print(sushi_plates.pop()) exit() answers = [0] * (n + 1) answers[1] = sushi_plates[0] for i in range(2, n + 1): answers[i] = max(answers[i - 1], answers[i - 2] + sushi_plates[i - 1]) print(answers[n])