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