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