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