import numpy as np N = int(input()) Vs = list(map(int, input().split())) dp = np.full_like(Vs, -1) for i in range(len(Vs)): if i == 0: dp[i] = Vs[i] elif i == 1: dp[i] = max(dp[i-1], Vs[i]) else: dp[i] = max(dp[i-1], dp[i-2] + Vs[i]) print(dp[N-1])